本文整理汇总了PHP中Form_Input类的典型用法代码示例。如果您正苦于以下问题:PHP Form_Input类的具体用法?PHP Form_Input怎么用?PHP Form_Input使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Form_Input类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addInput
public function addInput(Form_Input $input)
{
$group = new Form_Group($input->getTitle());
$group->add($input);
$this->add($group);
return $input;
}
示例2: addPassword
public function addPassword(Form_Input $input)
{
$group = new Form_Group($input->getTitle());
if ($input->getValue() != "") {
$input->setValue(DMYPWD);
}
$input->setType("password");
$group->add($input);
$confirm = clone $input;
$confirm->setName($confirm->getName() . "_confirm");
$confirm->setHelp("Confirm");
$group->add($confirm);
$this->add($group);
return $input;
}
示例3: Form_Section
$ro = "readonly";
}
$section = new Form_Section('User Properties');
$section->addInput(new Form_StaticText('Defined by', strtoupper($pconfig['utype'])));
$form->addGlobal(new Form_Input('utype', null, 'hidden', $pconfig['utype']));
$section->addInput(new Form_Checkbox('disabled', 'Disabled', 'This user cannot login', $pconfig['disabled']));
$section->addInput($input = new Form_Input('usernamefld', 'Username', 'text', $pconfig['usernamefld']));
if ($ro) {
$input->setReadonly();
}
$form->addGlobal(new Form_Input('oldusername', null, 'hidden', $pconfig['usernamefld']));
$group = new Form_Group('Password');
$group->add(new Form_Input('passwordfld1', 'Password', 'password'));
$group->add(new Form_Input('passwordfld2', 'Confirm Password', 'password'));
$section->add($group);
$section->addInput($input = new Form_Input('descr', 'Full name', 'text', htmlspecialchars($pconfig['descr'])))->setHelp('User\'s full name, for your own information only');
if ($ro) {
$input->setDisabled();
}
$section->addInput(new Form_Input('expires', 'Expiration date', 'date', $pconfig['expires']))->setHelp('Leave blank if the account shouldn\'t expire, otherwise enter ' . 'the expiration date');
// ==== Group membership ==================================================
$group = new Form_Group('Group membership');
// Make a list of all the groups configured on the system, and a list of
// those which this user is a member of
$systemGroups = array();
$usersGroups = array();
$usergid = [$pconfig['usernamefld']];
foreach ($config['system']['group'] as $Ggroup) {
if ($Ggroup['name'] != "all") {
if ($act == 'edit' && $Ggroup['member'] && in_array($pconfig['uid'], $Ggroup['member'])) {
$usersGroups[$Ggroup['name']] = $Ggroup['name'];
示例4: l2tp_users_sort
if (isset($id) && $a_secret[$id]) {
$a_secret[$id] = $secretent;
} else {
$a_secret[] = $secretent;
}
l2tp_users_sort();
write_config();
$retval = vpn_l2tp_configure();
pfSenseHeader("vpn_l2tp_users.php");
exit;
}
}
include "head.inc";
if ($input_errors) {
print_input_errors($input_errors);
}
$form = new Form();
$section = new Form_Section("User");
$section->addInput(new Form_Input('usernamefld', 'Username', 'text', $pconfig['usernamefld']));
$pwd = new Form_Input('passwordfld', 'Password', 'text', $pconfig['passwordfld']);
if (isset($id) && $a_secret[$id]) {
$pwd->setHelp('If you want to change the users password, enter it here.');
}
$section->addPassword($pwd);
$section->addInput(new Form_IpAddress('ip', 'IP Address', $pconfig['ip']))->setHelp('If you want the user to be assigned a specific IP address, enter it here.');
$form->add($section);
if (isset($id) && $a_secret[$id]) {
$form->addGlobal(new Form_Input('id', null, 'hidden', $i));
}
print $form;
include "foot.inc";
示例5: validate
public function validate()
{
// The upload directory must always be set
empty($this->directory) and $this->directory();
// By default, there is no uploaded file
$filename = '';
if ($status = parent::validate() and $this->upload['error'] === UPLOAD_ERR_OK) {
// Set the filename to the original name
$filename = $this->upload['name'];
if (Kohana::config('upload.remove_spaces')) {
// Remove spaces, due to global upload configuration
$filename = preg_replace('/\\s+/', '_', $this->data['value']);
}
if (file_exists($filepath = $this->directory . $filename)) {
if ($this->filename !== TRUE or !is_writable($filepath)) {
// Prefix the file so that the filename is unique
$filepath = $this->directory . 'uploadfile-' . uniqid(time()) . '-' . $this->upload['name'];
}
}
// Move the uploaded file to the upload directory
move_uploaded_file($this->upload['tmp_name'], $filepath);
}
if (!empty($_POST[$this->data['name']])) {
// Reset the POST value to the new filename
$this->data['value'] = $_POST[$this->data['name']] = empty($filepath) ? '' : $filepath;
}
return $status;
}
示例6: _getInput
protected function _getInput()
{
$element = parent::_getInput();
$options = '';
foreach ($this->_values as $value => $name) {
// Things can get weird if we have mixed types
$sval = $this->_value;
if (gettype($value) == "integer" && gettype($sval) == "string") {
$value = strval($value);
}
if (isset($this->_attributes['multiple'])) {
$selected = in_array($value, (array) $sval);
} else {
$selected = $sval == $value;
}
if (!empty(trim($name)) || is_numeric($name)) {
$name_str = htmlspecialchars(gettext($name));
} else {
// Fixes HTML5 validation: Element option without attribute label must not be empty
$name_str = " ";
}
$options .= '<option value="' . htmlspecialchars($value) . '"' . ($selected ? ' selected' : '') . '>' . $name_str . '</option>';
}
return <<<EOT
\t{$element}
\t\t{$options}
\t</select>
EOT;
}
示例7: _getInput
protected function _getInput()
{
$element = parent::_getInput();
$options = '';
foreach ($this->_values as $value => $name) {
// Things can get wierd if we have mixed types
$sval = $this->_value;
if (gettype($value) == "integer" && gettype($sval) == "string") {
$value = strval($value);
}
if (isset($this->_attributes['multiple'])) {
$selected = in_array($value, (array) $sval);
} else {
$selected = $sval == $value;
}
if (!empty($name) || $name == '0') {
$options .= '<option value="' . htmlspecialchars($value) . '"' . ($selected ? ' selected' : '') . '>' . htmlspecialchars(gettext($name)) . '</option>';
}
}
return <<<EOT
\t{$element}
\t\t{$options}
\t</select>
EOT;
}
示例8: is_valid
public function is_valid($value)
{
$name = $this->attrs['name'];
if (isset($_FILES[$name])) {
$value = isset($_FILES[$name]) ? $_FILES[$name]['name'] : null;
if (parent::is_valid($value)) {
if (!$this->required) {
return true;
}
if (!empty($this->extensions)) {
$ext = pathinfo($value, PATHINFO_EXTENSION);
if (!in_array($ext, $this->extensions)) {
$this->_error('invalid_file_extension');
$valid = false;
}
}
if (0 < $this->max_size && $this->max_size < $_FILES[$name]['size']) {
$this->_error('file_too_big');
$valid = false;
}
return $_FILES[$name]['error'] == UPLOAD_ERR_OK && is_uploaded_file($_FILES[$name]['tmp_name']);
}
}
return false;
}
示例9: _getInput
protected function _getInput()
{
$input = parent::_getInput();
if (!isset($this->_attributes['href'])) {
return $input;
}
return $input . htmlspecialchars($this->_title) . '</a>';
}
示例10: _getInput
protected function _getInput()
{
$input = parent::_getInput();
if (empty($this->_description)) {
return '<label class="chkboxlbl">' . $input . '</label>';
}
return '<label class="chkboxlbl">' . $input . ' ' . htmlspecialchars(gettext($this->_description)) . '</label>';
}
示例11: __get
public function __get($key)
{
if ($key == 'value') {
// Return the value if the checkbox is checked
return $this->data['checked'] ? $this->data['value'] : NULL;
}
return parent::__get($key);
}
示例12: _getInput
protected function _getInput()
{
$element = parent::_getInput();
$value = htmlspecialchars($this->_value);
return <<<EOT
\t{$element}{$value}</textarea>
EOT;
}
示例13: _getInput
protected function _getInput()
{
$input = parent::_getInput();
if (!isset($this->_description)) {
return $input;
}
return '<label>' . $input . ' ' . htmlspecialchars(gettext($this->_description)) . '</label>';
}
示例14: __call
public function __call($method, $args)
{
if (isset($this->parts[substr($method, 0, -1)])) {
// Set options for date generation
$this->parts[substr($method, 0, -1)] = $args;
return $this;
}
return parent::__call($method, $args);
}
示例15: is_valid
public function is_valid($value)
{
if (parent::is_valid($value)) {
if ($this->required && !empty($this->value) && $value != $this->value) {
$this->_error('incorrect_value');
return false;
}
return true;
}
return false;
}