protected $_filterType = 'simple';
protected $_filterValues = null;
+ protected $_prefix = null;
+ protected $_suffix = null;
+
protected $_adminType = 'text';
protected $_viewNamespace = 'crud::fields';
protected $_columnViewNamespace = 'crud::columns';
public function getDefaultAttributes()
{
- return ['type' => $this->_adminType, 'view_namespace' => $this->_viewNamespace, 'column' => false, 'form' => 'both', 'rules' => '',
+ return [
+ 'type' => $this->_adminType, 'view_namespace' => $this->_viewNamespace, 'column' => false, 'form' => 'both', 'rules' => '',
+ 'prefix' => $this->_prefix, 'suffix' => $this->_suffix,
'fillable' => true, 'guarded' => false, 'hidden' => false,
'filter' => false, 'filter_type' => $this->_filterType, 'filter_label' => null, 'filter_values' => $this->_filterValues,
'translatable' => $this->_translatable, 'migrateTranslatable' => $this->_migrateTranslatable,
+++ /dev/null
-<?php
-
-
-namespace Cubist\Backpack\Magic\Fields;
-
-
-class FolderTree extends SelectFromArray
-{
- protected $_root = '';
-
- /**
- * @param string $root
- */
- public function setRoot(string $root): void
- {
- $this->_root = $root;
- }
-
- /**
- * @return string
- */
- public function getRoot(): string
- {
- return $this->_root;
- }
-
- /**
- * @return array
- */
- public function getOptions(): array
- {
- $options = [];
-
- $iterator = \Cubist\Util\Files\Files::getRecursiveDirectoryIterator($this->getRoot());
-
- foreach ($iterator as $item) {
- /** @var $item \SplFileInfo */
- if ($item->isFile()) {
- continue;
- }
- $options[$item->getFilename()] = $item->getFilename();
- }
- return $options;
- }
-}
public function getDefaultAttributes()
{
- return array_merge(parent::getDefaultAttributes(), ['options' => $this->_options, 'options_aliases' => $this->_options_aliases, 'allows_null' => $this->_allowNull, 'allows_multiple' => $this->_multiple]);
+ return array_merge(parent::getDefaultAttributes(), ['options' => $this->getOptions(), 'options_aliases' => $this->_options_aliases, 'allows_null' => $this->_allowNull, 'allows_multiple' => $this->_multiple]);
+ }
+
+ public function getOptions()
+ {
+ return $this->_options;
}
public function getColumnData()
use Cubist\Backpack\CubistBackpackServiceProvider;
-use Illuminate\Support\Facades\Http;
+use Cubist\Backpack\CubistCrudPanel;
+use Cubist\Backpack\Magic\Fields\Field;
+use Cubist\Backpack\Magic\Models\CubistMagicAbstractModel;
class Form extends SubForm
{
protected $_enctype = 'application/x-www-form-urlencoded';
protected $_csrf = true;
protected $_title = '';
-
+ protected $crud;
public function __construct($action = '', $method = 'post')
{
$this->setAction($action);
$this->setMethod($method);
+ $this->crud = new CubistCrudPanel();
+ $this->crud->model=new CubistMagicAbstractModel();
parent::__construct();
+
}
/**
public function render(callable $callback = null)
{
- return view(CubistBackpackServiceProvider::NAMESPACE . '::form.form', ['form' => $this])->render($callback);
+ return view(CubistBackpackServiceProvider::NAMESPACE . '::form.form', ['form' => $this, 'crud' => $this->crud])->render($callback);
}
public function __toString()
return [];
}
- public function fields()
+ public function addField($name, $type = 'Text', $label = '', $attributes = [])
{
- return [];
+ $field = parent::addField($name, $type, $label, $attributes);
+ $this->crud->addField($field->getDefinition());
+
+ return $field;
}
- public function getAutoFocusOnFirstField(){
+ public function getAutoFocusOnFirstField()
+ {
return true;
}
- public function inlineErrorsEnabled(){
+ public function inlineErrorsEnabled()
+ {
return false;
}
}
@php
- $crud=$form;
$action='create';
- $fields=$form->fields();
+ $fields=$crud->fields();
@endphp
<h2>{{$form->getTitle()}}</h2>