本文整理汇总了PHP中Fieldset::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Fieldset::factory方法的具体用法?PHP Fieldset::factory怎么用?PHP Fieldset::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fieldset
的用法示例。
在下文中一共展示了Fieldset::factory方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set_fields
/**
* Set a Model's properties as fields on a Fieldset, which will be created with the Model's
* classname if none is provided.
*
* @param string
* @param Fieldset|null
* @return Fieldset
*/
public static function set_fields($class, $fieldset = null)
{
$properties = $class::properties();
if (is_null($fieldset)) {
$fieldset = \Fieldset::instance($class);
if (!$fieldset) {
$fieldset = \Fieldset::factory($class);
}
}
foreach ($properties as $p => $settings) {
$field = $fieldset->add($p, !empty($settings['label']) ? $settings['label'] : $p);
if (empty($settings['validation'])) {
continue;
} else {
foreach ($settings['validation'] as $rule => $args) {
if (is_int($rule) and is_string($args)) {
$args = array($args);
} else {
array_unshift($args, $rule);
}
call_user_func_array(array($field, 'add_rule'), $args);
}
}
}
return $fieldset;
}
示例2: set_fields
/**
* Set a Model's properties as fields on a Fieldset, which will be created with the Model's
* classname if none is provided.
*
* @param string
* @param Fieldset|null
* @return Fieldset
*/
public static function set_fields($obj, $fieldset = null)
{
static $_generated = array();
$class = is_object($obj) ? get_class($obj) : $obj;
if (is_null($fieldset)) {
$fieldset = \Fieldset::instance($class);
if (!$fieldset) {
$fieldset = \Fieldset::factory($class);
}
}
!array_key_exists($class, $_generated) and $_generated[$class] = array();
if (in_array($fieldset, $_generated[$class], true)) {
return $fieldset;
}
$_generated[$class][] = $fieldset;
$fieldset->validation()->add_callable($obj);
$properties = is_object($obj) ? $obj->properties() : $class::properties();
foreach ($properties as $p => $settings) {
$field = $fieldset->add($p, !empty($settings['label']) ? $settings['label'] : $p);
if (empty($settings['validation'])) {
continue;
} else {
foreach ($settings['validation'] as $rule => $args) {
if (is_int($rule) and is_string($args)) {
$args = array($args);
} else {
array_unshift($args, $rule);
}
call_user_func_array(array($field, 'add_rule'), $args);
}
}
}
return $fieldset;
}
示例3: __construct
protected function __construct($fieldset)
{
if (!$fieldset instanceof Fieldset) {
$fieldset = Fieldset::factory($fieldset, array('validation_instance' => $this));
}
$this->fieldset = $fieldset;
$this->callables = array($this);
}
示例4: factory
public static function factory($fieldset)
{
if ( ! $fieldset instanceof Fieldset)
{
$fieldset = (string) $fieldset;
if ( ! ($fieldset = \Fieldset::instance($fieldset)))
{
$fieldset = \Fieldset::factory($fieldset);
}
}
return new Validation($fieldset);
}
示例5: factory
public static function factory($fieldset, $config)
{
if ( ! $fieldset instanceof Fieldset)
{
$fieldset = (string) $fieldset;
if ( ! ($fieldset = \Fieldset::instance($fieldset)))
{
$fieldset = \Fieldset::factory($fieldset, $config);
}
}
return new Form($fieldset);
}
示例6: __construct
protected function __construct($fieldset, array $config = array())
{
if ($fieldset instanceof Fieldset) {
$fieldset->form($this);
$this->fieldset = $fieldset;
} else {
$this->fieldset = \Fieldset::factory($fieldset, array('form_instance' => $this));
}
foreach ($config as $key => $val) {
$this->set_config($key, $val);
}
}