Remove section from Form 28/09/2015
In form factory call:
$user = $form->addContainer('user'); $user->addText('username', 'Username'); Everything added to container $user is now in own namespace. You can separate it in values processing like this:
$userValues = array_pick($values, 'user'); And this is array_pick:
/** * Pick element from the array by key and return its value. * @param array * @param string|int array key * @param mixed default value when item is not present * @return mixed * @throws Nette\InvalidArgumentException if item does not exist and default value is not provided */ function array_pick(& $arr, $key, $default = NULL) { if (array_key_exists($key, $arr)) { $value = $arr[$key]; unset($arr[$key]); return $value; } else { if (func_num_args() < 3) { throw new Nette\InvalidArgumentException("Missing item '$key'.
In form factory call:
$user = $form->addContainer('user');
$user->addText('username', 'Username');
Everything added to container $user is now in own namespace. You can separate it in values processing like this:
$userValues = array_pick($values, 'user');
And this is array_pick:
/**
* Pick element from the array by key and return its value.
* @param array
* @param string|int array key
* @param mixed default value when item is not present
* @return mixed
* @throws Nette\InvalidArgumentException if item does not exist and default value is not provided
*/
function array_pick(& $arr, $key, $default = NULL)
{
if (array_key_exists($key, $arr)) {
$value = $arr[$key];
unset($arr[$key]);
return $value;
} else {
if (func_num_args() < 3) {
throw new Nette\InvalidArgumentException("Missing item '$key'.");
}
return $default;
}
}
from foxycode September 17, 2015 3:00 AM