|
@@ -8,64 +8,7 @@ use Dcat\Admin\Widgets\Form as WidgetForm;
|
|
|
use Illuminate\Support\Arr;
|
|
|
use Illuminate\Support\Collection;
|
|
|
|
|
|
-/**
|
|
|
- * Class Form.
|
|
|
- *
|
|
|
- * @method Field\Text text($column, $label = '')
|
|
|
- * @method Field\Checkbox checkbox($column, $label = '')
|
|
|
- * @method Field\Radio radio($column, $label = '')
|
|
|
- * @method Field\Select select($column, $label = '')
|
|
|
- * @method Field\MultipleSelect multipleSelect($column, $label = '')
|
|
|
- * @method Field\Textarea textarea($column, $label = '')
|
|
|
- * @method Field\Hidden hidden($column, $label = '')
|
|
|
- * @method Field\Id id($column, $label = '')
|
|
|
- * @method Field\Ip ip($column, $label = '')
|
|
|
- * @method Field\Url url($column, $label = '')
|
|
|
- * @method Field\Email email($column, $label = '')
|
|
|
- * @method Field\Mobile mobile($column, $label = '')
|
|
|
- * @method Field\Slider slider($column, $label = '')
|
|
|
- * @method Field\Map map($latitude, $longitude, $label = '')
|
|
|
- * @method Field\Editor editor($column, $label = '')
|
|
|
- * @method Field\Date date($column, $label = '')
|
|
|
- * @method Field\Datetime datetime($column, $label = '')
|
|
|
- * @method Field\Time time($column, $label = '')
|
|
|
- * @method Field\Year year($column, $label = '')
|
|
|
- * @method Field\Month month($column, $label = '')
|
|
|
- * @method Field\DateRange dateRange($start, $end, $label = '')
|
|
|
- * @method Field\DateTimeRange datetimeRange($start, $end, $label = '')
|
|
|
- * @method Field\TimeRange timeRange($start, $end, $label = '')
|
|
|
- * @method Field\Number number($column, $label = '')
|
|
|
- * @method Field\Currency currency($column, $label = '')
|
|
|
- * @method Field\SwitchField switch($column, $label = '')
|
|
|
- * @method Field\Display display($column, $label = '')
|
|
|
- * @method Field\Rate rate($column, $label = '')
|
|
|
- * @method Field\Divide divider()
|
|
|
- * @method Field\Password password($column, $label = '')
|
|
|
- * @method Field\Decimal decimal($column, $label = '')
|
|
|
- * @method Field\Html html($html, $label = '')
|
|
|
- * @method Field\Tags tags($column, $label = '')
|
|
|
- * @method Field\Icon icon($column, $label = '')
|
|
|
- * @method Field\Embeds embeds($column, $label = '')
|
|
|
- * @method Field\Captcha captcha()
|
|
|
- * @method Field\Listbox listbox($column, $label = '')
|
|
|
- * @method Field\File file($column, $label = '')
|
|
|
- * @method Field\Image image($column, $label = '')
|
|
|
- * @method Field\MultipleFile multipleFile($column, $label = '')
|
|
|
- * @method Field\MultipleImage multipleImage($column, $label = '')
|
|
|
- * @method Field\HasMany hasMany($column, $labelOrCallback, $callback = null)
|
|
|
- * @method Field\Tree tree($column, $label = '')
|
|
|
- * @method Field\Table table($column, $labelOrCallback, $callback = null)
|
|
|
- * @method Field\ListField list($column, $label = '')
|
|
|
- * @method Field\Timezone timezone($column, $label = '')
|
|
|
- * @method Field\KeyValue keyValue($column, $label = '')
|
|
|
- * @method Field\Tel tel($column, $label = '')
|
|
|
- * @method Field\Markdown markdown($column, $label = '')
|
|
|
- * @method Field\Range range($start, $end, $label = '')
|
|
|
- * @method Field\Color color($column, $label = '')
|
|
|
- * @method Field\SelectTable selectTable($column, $label = '')
|
|
|
- * @method Field\MultipleSelectTable multipleSelectTable($column, $label = '')
|
|
|
- */
|
|
|
-class NestedForm
|
|
|
+class NestedForm extends WidgetForm
|
|
|
{
|
|
|
use Form\Concerns\HandleCascadeFields;
|
|
|
use Form\Concerns\HasRows;
|
|
@@ -117,13 +60,18 @@ class NestedForm
|
|
|
* @param string $relation
|
|
|
* @param null $key
|
|
|
*/
|
|
|
- public function __construct($relation, $key = null)
|
|
|
+ public function __construct($relation = null, $key = null)
|
|
|
{
|
|
|
$this->relationName = $relation;
|
|
|
|
|
|
$this->key = $key;
|
|
|
|
|
|
- $this->fields = new Collection();
|
|
|
+ $this->disableResetButton();
|
|
|
+ $this->disableSubmitButton();
|
|
|
+ $this->ajax(false);
|
|
|
+ $this->useFormTag(false);
|
|
|
+
|
|
|
+ parent::__construct();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -334,6 +282,10 @@ class NestedForm
|
|
|
{
|
|
|
$this->fields->push($field);
|
|
|
|
|
|
+ if ($this->layout()->hasColumns()) {
|
|
|
+ $this->layout()->addField($field);
|
|
|
+ }
|
|
|
+
|
|
|
if (method_exists($this->form, 'builder')) {
|
|
|
$this->form->builder()->fields()->push($field);
|
|
|
$field->attribute(Builder::BUILD_IGNORE, true);
|
|
@@ -346,6 +298,8 @@ class NestedForm
|
|
|
|
|
|
$field::requireAssets();
|
|
|
|
|
|
+ $field->width($this->width['field'], $this->width['label']);
|
|
|
+
|
|
|
return $this;
|
|
|
}
|
|
|
|
|
@@ -366,7 +320,7 @@ class NestedForm
|
|
|
*
|
|
|
* @return $this
|
|
|
*/
|
|
|
- public function fill(array $data)
|
|
|
+ public function fill($data)
|
|
|
{
|
|
|
/* @var Field $field */
|
|
|
foreach ($this->fields() as $field) {
|
|
@@ -376,24 +330,6 @@ class NestedForm
|
|
|
return $this;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Get the html and script of template.
|
|
|
- *
|
|
|
- * @return string
|
|
|
- */
|
|
|
- public function getTemplate()
|
|
|
- {
|
|
|
- $html = '';
|
|
|
-
|
|
|
- /* @var Field $field */
|
|
|
- foreach ($this->fields() as $field) {
|
|
|
- //when field render, will push $script to Admin
|
|
|
- $html .= $field->render();
|
|
|
- }
|
|
|
-
|
|
|
- return $html;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Set `errorKey` `elementName` `elementClass` for fields inside hasmany fields.
|
|
|
*
|