toastnz / silverstripe-design-field
Silverstripe Design Field
0.1.1
2015-08-26 04:56 UTC
Requires
This package is not auto-updated.
Last update: 2024-09-18 08:27:35 UTC
README
#Silverstripe Design Field 一个可以生成对象内联样式的字段。该字段以JSON字符串的形式保存在数据库中。以下是输出示例
{ "selector":".myobject", "padding-top":"100px", "padding-bottom":"100px", "margin-top":"10px", "margin-bottom":"10px", "background":"#ffffff" }
###方法摘要
- | - ---- | ---- public | __construct($name, $title = null, $selector = null, $fields = null, $value = null) $fields参数几乎支持所有silverstripe字段,除了UploadFields和FileFields。###截图
###示例用法
private static $db = array( 'MyObject' => 'Design' );
DesignField::create('MyObject', _t('DesignField.MyObject', 'My Object'), '.myobject', array( 'padding-top' => 'TextField', 'padding-right' => 'TextField', 'padding-bottom' => 'TextField', 'padding-left' => 'TextField', 'margin-top' => 'TextField', 'margin-right' => 'TextField', 'margin-bottom' => 'TextField', 'margin-left' => 'TextField', 'color' => 'ColorField', 'background' => 'ColorField', 'font-size' => array( 'type' => 'DropdownField', 'value' => array( '16px', '25px', '36px' ) ) ));
返回样式字符串
$this->dbObject('MyObject')->InlineStyle();