本文整理汇总了PHP中Formo::field方法的典型用法代码示例。如果您正苦于以下问题:PHP Formo::field方法的具体用法?PHP Formo::field怎么用?PHP Formo::field使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Formo
的用法示例。
在下文中一共展示了Formo::field方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: html
public function html()
{
foreach ($this->field->get('options') as $label => $options) {
$this->field->append(Formo::field($label, 'option', $options));
}
$this->decorator->set('tag', 'select')->attr('name', $this->name());
}
示例2: html
public function html()
{
foreach ($this->_field->get('options') as $label => $options)
{
$this->_field->append(Formo::field($label, 'radio', $options));
}
}
示例3: html
public function html()
{
foreach ($this->_field->get('options') as $label => $options) {
$this->_field->append(Formo::field($label, 'option', $options));
}
$this->_view->set_var('tag', 'optgroup')->attr('label', $this->_field->alias());
}
示例4: html
public function html()
{
foreach ($this->_field->get('options') as $alias => $options)
{
$this->_field->append(Formo::field($alias, 'checkbox', $options));
}
}
示例5: html
public function html()
{
$this->render_field->append(Formo::field('', 'option'));
foreach ($this->render_field->options as $label => $options) {
$this->render_field->append(Formo::field($label, 'option', $options));
}
$this->render_field->set('tag', 'select')->attr('name', $this->field->alias());
}
示例6: add
/**
* Adds a field to a form
*
* @access public
* @param mixed $alias
* @param mixed $driver. (default: NULL)
* @param mixed $value. (default: NULL)
* @param mixed array $options. (default: NULL)
* @return object
*/
public function add($alias, $driver = NULL, $value = NULL, array $options = NULL)
{
// If Formo instnace was passed
if ($alias instanceof Formo_Form) {
return $this->add_object($alias);
}
if ($driver instanceof Formo_Form) {
return $this->add_object($driver->alias($alias));
}
if ($value instanceof Formo_Form) {
return $this->add_object($value->set('driver', $driver)->alias($alias));
}
$orig_options = $options;
$options = func_get_args();
$options = Formo::args(__CLASS__, __FUNCTION__, $options);
// If a driver is named but not an alias, make the driver text and the alias the driver
if (empty($options['driver'])) {
$options['driver'] = Arr::get($this->config, 'default_driver', 'text');
}
// Allow loading rules, callbacks, filters upon adding a field
$validate_options = array('rules', 'triggers', 'filters');
// Create the array
$validate_settings = array();
foreach ($validate_options as $option) {
if (!empty($options[$option])) {
$validate_settings[$option] = $options[$option];
unset($options[$option]);
}
}
// Create the new field
$field = Formo::field($options);
$this->append($field);
// Add the validation rules
foreach ($validate_settings as $method => $array) {
foreach ($array as $callback => $opts) {
if ($opts instanceof Formo_Validator_Item) {
// The rules method will suffice for all Formo_Validator_Item objects
$field->rules(NULL, $opts);
continue;
}
$args = array(NULL, $callback, $opts);
call_user_func_array(array($field, $method), $args);
}
}
return $this;
}
示例7: add
/**
* Adds a field to a form
*
* @access public
* @param mixed $alias
* @param mixed $driver. (default: NULL)
* @param mixed $value. (default: NULL)
* @param mixed array $options. (default: NULL)
* @return object
*/
public function add($alias, $driver = NULL, $value = NULL, array $options = NULL)
{
// If Formo instnace was passed
if ($alias instanceof Formo_Form) {
return $this->_add_object($alias);
}
if ($driver instanceof Formo_Form) {
return $this->_add_object($driver->alias($alias));
}
if ($value instanceof Formo_Form) {
return $this->_add_object($value->set('driver', $driver)->alias($alias));
}
$orig_options = $options;
$options = func_get_args();
$options = Formo::args(__CLASS__, __FUNCTION__, $options);
// If a driver is named but not an alias, make the driver text and the alias the driver
if (empty($options['driver'])) {
$options['driver'] = ($driver = Formo::config($this, 'default_driver')) ? $driver : 'input';
}
// Create the new field
$field = Formo::field($options);
$this->append($field);
return $this;
}