first commit
This commit is contained in:
37
app/Fields/IframeField.php
Normal file
37
app/Fields/IframeField.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Fields;
|
||||
|
||||
use Backpack\CRUD\app\Library\CrudPanel\CrudField;
|
||||
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade;
|
||||
|
||||
class IframeField
|
||||
{
|
||||
/**
|
||||
* Create an iframe custom field.
|
||||
*
|
||||
* @param string $name Field name (not used for display, only for form data)
|
||||
* @param string $label Field label
|
||||
* @param array $options Additional options (url, width, height, extra_attributes, hint)
|
||||
* @return CrudField
|
||||
*/
|
||||
public static function make(string $name, string $label, array $options = [])
|
||||
{
|
||||
$url = isset($options['url']) && is_callable($options['url'])
|
||||
? $options['url'](CrudPanelFacade::getFacadeRoot())
|
||||
: ($options['url'] ?? null);
|
||||
|
||||
$field = [
|
||||
'name' => $name,
|
||||
'label' => $label,
|
||||
'type' => 'iframe',
|
||||
'url' => $url, // URL to display in iframe
|
||||
'width' => $options['width'] ?? '', // Iframe width
|
||||
'height' => $options['height'] ?? '', // Iframe height
|
||||
'extra_attributes' => $options['extra_attributes'] ?? [], // Additional iframe attributes
|
||||
'hint' => $options['hint'] ?? null, // Help text
|
||||
];
|
||||
|
||||
return \Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade::field($field);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user