public function state($options = array())
    {
        $options = new AnConfig($options);

        $options->append(array(
            'country_selector' => 'countery-selector',
            'country' => 'US',
            'selected' => null,
            'use_state_code' => true,
            'prompt' => true,
        ));

        $country = strtolower($options->country);

        $country_selector = null;

        if ($options->country_selector) {
            $country_selector = $options->country_selector;
        }

        $use_state_code = $options->use_state_code;

        unset($options->use_state_code);
        unset($options->country);
        unset($options->country_selector);

        $states = array();
        $provinces = array();

        foreach (self::$US_STATES as $key => $name) {
            $states[$use_state_code ? $key : $name] = AnTranslator::_($name);
        }

        foreach (self::$CANADA_PROVINCES as $key => $name) {
            $provinces[$use_state_code ? $key : $name] = AnTranslator::_($name);
        }

        $selected = $options->selected;

        unset($options->selected);

        $options = AnConfig::unbox($options);

        $states = $this->_html->select($options['name'], array('options' => $states, 'selected' => $selected), array_merge($options, array('country' => 'us')));
        $provinces = $this->_html->select($options['name'], array('options' => $provinces, 'selected' => $selected), array_merge($options, array('country' => 'canada')));
        $custom = $this->_html->textfield($options['name'], $selected, array_merge($options, array('country' => 'custom')));

        if (empty($country_selector)) {
            return $country == 'us' ? $states : $provinces;
        }

        return $states.$provinces.$custom;
    }
public function state($options = array())
    {
        $options = new AnConfig($options);

        $options->append(array(
            'country_selector' => 'countery-selector',
            'country' => 'US',
            'selected' => null,
            'use_state_code' => true,
            'prompt' => true,
        ));

        $country = strtolower($options->country);

        $country_selector = null;

        if ($options->country_selector) {
            $country_selector = $options->country_selector;
        }

        $use_state_code = $options->use_state_code;

        unset($options->use_state_code);
        unset($options->country);
        unset($options->country_selector);

        $states = array();
        $provinces = array();

        foreach (self::$US_STATES as $key => $name) {
            $states[$use_state_code ? $key : $name] = AnTranslator::_($name);
        }

        foreach (self::$CANADA_PROVINCES as $key => $name) {
            $provinces[$use_state_code ? $key : $name] = AnTranslator::_($name);
        }

        $selected = $options->selected;

        unset($options->selected);

        $options = AnConfig::unbox($options);

        $states = $this->_html->select($options['name'], array('options' => $states, 'selected' => $selected), array_merge($options, array('country' => 'us')));
        $provinces = $this->_html->select($options['name'], array('options' => $provinces, 'selected' => $selected), array_merge($options, array('country' => 'canada')));
        $custom = $this->_html->textfield($options['name'], $selected, array_merge($options, array('country' => 'custom')));

        if (empty($country_selector)) {
            return $country == 'us' ? $states : $provinces;
        }

        return $states.$provinces.$custom;
    }
public function state ( $ options = array ( ) ) { $ options = new AnConfig ( $ options ) ; $ options -> append ( array ( 'country_selector' => 'countery-selector' , 'country' => 'US' , 'selected' => null , 'use_state_code' => true , 'prompt' => true , ) ) ; $ country = strtolower ( $ options -> country ) ; $ country_selector = null ; if ( $ options -> country_selector ) { $ country_selector = $ options -> country_selector ; } $ use_state_code = $ options -> use_state_code ; unset ( $ options -> use_state_code ) ; unset ( $ options -> country ) ; unset ( $ options -> country_selector ) ; $ states = array ( ) ; $ provinces = array ( ) ; foreach ( self :: $ US_STATES as $ key => $ name ) { $ states [ $ use_state_code ? $ key : $ name ] = AnTranslator :: _ ( $ name ) ; } foreach ( self :: $ CANADA_PROVINCES as $ key => $ name ) { $ provinces [ $ use_state_code ? $ key : $ name ] = AnTranslator :: _ ( $ name ) ; } $ selected = $ options -> selected ; unset ( $ options -> selected ) ; $ options = AnConfig :: unbox ( $ options ) ; $ states = $ this -> _html -> select ( $ options [ 'name' ] , array ( 'options' => $ states , 'selected' => $ selected ) , array_merge ( $ options , array ( 'country' => 'us' ) ) ) ; $ provinces = $ this -> _html -> select ( $ options [ 'name' ] , array ( 'options' => $ provinces , 'selected' => $ selected ) , array_merge ( $ options , array ( 'country' => 'canada' ) ) ) ; $ custom = $ this -> _html -> textfield ( $ options [ 'name' ] , $ selected , array_merge ( $ options , array ( 'country' => 'custom' ) ) ) ; if ( empty ( $ country_selector ) ) { return $ country == 'us' ? $ states : $ provinces ; } return $ states . $ provinces . $ custom ; }
Return a selection of states or provinces for canada.

@param array $options

@return LibBaseTemplateTag
Return a selection of states or provinces for canada .