本文整理汇总了PHP中Phalcon\Forms\Element\Text::setUserOption方法的典型用法代码示例。如果您正苦于以下问题:PHP Text::setUserOption方法的具体用法?PHP Text::setUserOption怎么用?PHP Text::setUserOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phalcon\Forms\Element\Text
的用法示例。
在下文中一共展示了Text::setUserOption方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initialize
/**
* @param Phalcon\Mvc\ModelInstance $entity
* @param array $options
*/
public function initialize($entity = null, $options = null)
{
if (!isset($options['edit']) && !isset($options['create'])) {
$id = new Text('id');
$id->setLabel('Id');
$this->add($id);
}
$category = new Select('categoriesId', Categories::find(), array('using' => array('id', 'name'), 'useEmpty' => true, 'emptyText' => '...'));
$category->setLabel('Category');
$category->addValidator(new PresenceOf(array('message' => 'Category is mandatory')));
$category->setUserOption('searcheable', true);
$category->setUserOption('browseable', true);
$category->setUserOption('relation', 'category');
$this->add($category);
$icon = new Text('icon', array('placeholder' => 'Enter a css-icon class name'));
$icon->setLabel('Icon');
$icon->addValidator(new PresenceOf(array('message' => 'Icon is mandatory')));
$this->add($icon);
$code = new Text('code', array('maxlength' => 10));
$code->setLabel('Code');
$code->setUserOption('searcheable', true);
$code->setUserOption('browseable', true);
$code->addValidator(new PresenceOf(array('message' => 'Code is mandatory')));
$this->add($code);
$name = new Text('name', array('maxlength' => 64));
$name->setLabel('Name');
$name->setUserOption('searcheable', true);
$name->setUserOption('browseable', true);
$name->addValidator(new PresenceOf(array('message' => 'Name is mandatory')));
$this->add($name);
$description = new TextArea('description');
$description->setLabel('Description');
$description->addValidator(new PresenceOf(array('message' => 'Description is mandatory')));
$this->add($description);
$price = new Text('price');
$price->setLabel('Price');
$price->setUserOption('searcheable', true);
$price->setUserOption('browseable', true);
$price->addValidator(new PresenceOf(array('message' => 'Price is mandatory')));
$price->addValidator(new Numericality(array('message' => 'Price must be a number')));
$this->add($price);
$stock = new Text('stock');
$stock->setLabel('Stock');
$stock->setUserOption('browseable', true);
$stock->addValidator(new PresenceOf(array('message' => 'Current stock is mandatory')));
$stock->addValidator(new Numericality(array('message' => 'Current stock must be a number')));
$this->add($stock);
if (isset($options['edit'])) {
$createdAt = new Date('created', array('readonly' => 'readonly'));
$createdAt->setLabel('Created At');
if ($entity->createdAt) {
$entity->created = date('Y-m-d', $entity->createdAt);
}
$this->add($createdAt);
}
}
示例2: initialize
public function initialize($entity = null, $options = null)
{
if (!isset($options['edit']) && !isset($options['create'])) {
$id = new Text('id');
$id->setLabel('Id');
$id->setUserOption('searcheable', true);
$id->setUserOption('browseable', true);
$this->add($id);
}
$shortName = new Text('shortName');
$shortName->setLabel('Short Name');
$shortName->setUserOption('searcheable', true);
$shortName->setUserOption('browseable', true);
$shortName->addValidator(new PresenceOf(array('message' => 'Short name is mandatory')));
$this->add($shortName);
$name = new Text('name');
$name->setLabel('Name');
$name->setUserOption('searcheable', true);
$name->setUserOption('browseable', true);
$name->addValidator(new PresenceOf(array('message' => 'Name is mandatory')));
$this->add($name);
}