Back to PasswordField class

Method setup

public bool
setup
(\SimpleXMLElement $element, mixed $value, mixed $group = null)
Method to attach a Form object to the field.
Parameters
  • \SimpleXMLElement $element The SimpleXMLElement object representing the `<field>` tag for the form field object.
  • mixed $value The form field value to validate.
  • string $group The field name group control value. This acts as an array container for the field. For example if the field has name="foo" and the group value is set to "bar" then the full field name would end up being "bar[foo]".
Returns
  • bool True on success.
Since
  • 3.2
-
  • \Joomla\CMS\Form\FormField::setup()
Class: PasswordField
Project: Joomla

Method setup - Source code

/**
 * Method to attach a Form object to the field.
 *
 * @param   \SimpleXMLElement  $element  The SimpleXMLElement object representing the `<field>` tag for the form field object.
 * @param   mixed              $value    The form field value to validate.
 * @param   string             $group    The field name group control value. This acts as an array container for the field.
 *                                       For example if the field has name="foo" and the group value is set to "bar" then the
 *                                       full field name would end up being "bar[foo]".
 *
 * @return  boolean  True on success.
 *
 * @see     FormField::setup()
 * @since   3.2
 */
public function setup(\SimpleXMLElement $element, $value, $group = null)
{
    $return = parent::setup($element, $value, $group);
    if ($return) {
        $lock = (string) $this->element['lock'];
        $this->lock = $lock === 'true' || $lock === 'on' || $lock === '1';
        $this->maxLength = $this->element['maxlength'] ? (int) $this->element['maxlength'] : 99;
        $this->threshold = $this->element['threshold'] ? (int) $this->element['threshold'] : 66;
        $meter = (string) $this->element['strengthmeter'];
        $this->meter = $meter === 'true' || $meter === 'on' || $meter === '1';
        $force = (string) $this->element['forcePassword'];
        $this->force = ($force === 'true' || $force === 'on' || $force === '1') && $this->meter === true;
        $rules = (string) $this->element['rules'];
        $this->rules = ($rules === 'true' || $rules === 'on' || $rules === '1') && $this->meter === true;
        // Set some initial values
        $this->minLength = 12;
        $this->minIntegers = 0;
        $this->minSymbols = 0;
        $this->minUppercase = 0;
        $this->minLowercase = 0;
        if (Factory::getApplication()->get('db') != '') {
            $this->minLength = (int) ComponentHelper::getParams('com_users')->get('minimum_length', 12);
            $this->minIntegers = (int) ComponentHelper::getParams('com_users')->get('minimum_integers', 0);
            $this->minSymbols = (int) ComponentHelper::getParams('com_users')->get('minimum_symbols', 0);
            $this->minUppercase = (int) ComponentHelper::getParams('com_users')->get('minimum_uppercase', 0);
            $this->minLowercase = (int) ComponentHelper::getParams('com_users')->get('minimum_lowercase', 0);
        }
    }
    return $return;
}