use Cubist\Backpack\CubistBackpackServiceProvider;
use Doctrine\DBAL\Schema\Table;
use Exception;
+use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Cubist\Backpack\Magic\Models\CubistMagicAbstractModel;
protected $_prefix = null;
protected $_suffix = null;
+ protected $_placeholder = null;
+
protected $_adminType = 'text';
protected $_viewNamespace = 'crud::fields';
protected $_columnViewNamespace = 'crud::columns';
'allow_null' => true,
'can' => $this->_can, 'can_write' => $this->_canWrite, 'auth' => $this->_auth,
'database_type' => $this->_databaseType, 'database_unique' => $this->_databaseUnique, 'database_index' => $this->_databaseIndex, 'database_default' => $this->_databaseDefault, 'database_length' => $this->_databaseLength,
- 'fake' => false, 'store_in' => 'extras', 'attributes' => []];
+ 'fake' => false, 'store_in' => 'extras', 'attributes' => [],
+ 'field_attributes.placeholder' => $this->_placeholder,
+ ];
}
public function __construct($attributes)
$res['view_namespace'] = CubistBackpackServiceProvider::NAMESPACE . '::fields';
$res['type'] = 'static_value';
}
+ $res['attributes'] = $this->getFieldAttributes();
+ return $res;
+ }
+
+ protected function getFieldAttributes()
+ {
+ $res = [];
+ foreach ($this->_attributes as $k => $v) {
+ if (null === $v) {
+ continue;
+ }
+ if (strstr($k, 'field_attributes.')) {
+ $e = explode('.', $k, 2);
+ Arr::set($res, $e[1], $v);
+ }
+ }
return $res;
}
protected $_translatable = true;
protected $_columnType = 'textarea';
protected $_columnViewNamespace = CubistBackpackServiceProvider::NAMESPACE . '::columns';
+ protected $_fieldHeight = 15;
+
+ public function getDefaultAttributes()
+ {
+ return array_merge(parent::getDefaultAttributes(), ['field_attributes.rows' => $this->_fieldHeight]);
+ }
}