本文整理汇总了PHP中Framework::getFieldSizes方法的典型用法代码示例。如果您正苦于以下问题:PHP Framework::getFieldSizes方法的具体用法?PHP Framework::getFieldSizes怎么用?PHP Framework::getFieldSizes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Framework
的用法示例。
在下文中一共展示了Framework::getFieldSizes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __callStatic
/**
* Creates a field instance
*
* @param string $method The field type
* @param array $parameters An array of parameters
* @return Former
*/
public static function __callStatic($method, $parameters)
{
// Form opener
if (str_contains($method, 'open')) {
static::$form = new Form();
return static::form()->open($method, $parameters);
}
// Avoid conflict with chained label method
if ($method == 'label') {
return call_user_func_array('static::_label', $parameters);
}
// Checking for any supplementary classes
$classes = explode('_', $method);
$method = array_pop($classes);
// Destroy previous field instance
static::$field = null;
// Picking the right class
if (class_exists('\\Former\\Fields\\' . ucfirst($method))) {
$callClass = ucfirst($method);
} else {
switch ($method) {
case 'multiselect':
$callClass = 'Select';
break;
case 'checkboxes':
$callClass = 'Checkbox';
break;
case 'radios':
$callClass = 'Radio';
break;
case 'files':
$callClass = 'File';
break;
default:
$callClass = 'Input';
break;
}
}
// Listing parameters
$class = '\\Former\\Fields\\' . $callClass;
static::$field = new $class($method, array_get($parameters, 0), array_get($parameters, 1), array_get($parameters, 2), array_get($parameters, 3), array_get($parameters, 4), array_get($parameters, 5));
// Inline checkboxes
if (in_array($callClass, array('Checkbox', 'Radio')) and in_array('inline', $classes)) {
static::$field->inline();
}
// Add any size we found
$size = Framework::getFieldSizes($classes);
if ($size) {
static::$field->addClass($size);
}
return new Former();
}
示例2: __callStatic
/**
* Creates a field instance
*
* @param string $method The field type
* @param array $parameters An array of parameters
* @return Former
*/
public static function __callStatic($method, $parameters)
{
// Form opener
if (str_contains($method, 'open')) {
static::$form = new Form();
static::form()->open($method, $parameters);
return new static();
}
// Avoid conflict with chained label method
if ($method == 'label') {
return call_user_func_array('static::_label', $parameters);
}
// Checking for any supplementary classes
$classes = explode('_', $method);
$method = array_pop($classes);
// Destroy previous field instance
static::$field = null;
// Picking the right class
if (class_exists(static::FIELDSPACE . ucfirst($method))) {
$callClass = ucfirst($method);
} else {
switch ($method) {
case 'submit':
case 'reset':
$callClass = 'Button';
break;
case 'multiselect':
$callClass = 'Select';
break;
case 'checkboxes':
$callClass = 'Checkbox';
break;
case 'radios':
$callClass = 'Radio';
break;
case 'files':
$callClass = 'File';
break;
default:
$callClass = 'Input';
break;
}
}
// Check for potential errors
if (!class_exists(static::FIELDSPACE . $callClass)) {
throw new \Exception('The class "' . static::FIELDSPACE . $callClass . '" called by field "' . $method . '" doesn\'t exist');
}
// Listing parameters
$class = static::FIELDSPACE . $callClass;
static::$field = new $class($method, array_get($parameters, 0), array_get($parameters, 1), array_get($parameters, 2), array_get($parameters, 3), array_get($parameters, 4), array_get($parameters, 5));
// Inline checkboxes
if (in_array($callClass, array('Checkbox', 'Radio')) and in_array('inline', $classes)) {
static::$field->inline();
}
// Filter classes according to field type
$classes = $callClass == 'Button' ? Framework::getButtonTypes($classes) : Framework::getFieldSizes($classes);
// Add any supplementary classes we found
if ($classes) {
static::$field->addClass($classes);
}
// As Buttons are more of a helper class, we return them directly
if ($callClass == 'Button') {
return static::$field;
}
return new static();
}