Jump to content

Recommended Posts

I hope I am in the right place. I have a country array and I need the USA value to be the default value. what changes to the empty"=>"-Select-")); do i need. If I change select to USA it is just a lable. I am trying to select a value in the array an make it the current record.

 

    App::import("Vendor","ListingFieldProperties");
    }
    ?>
    <h2 class="module_title"><?php echo __("Select Country");?></h2>
    <?php
    $options = ListingFieldProperties::getCountriesOptions();
    echo $form->input(ListingFieldProperties::COUNTRY_FIELD,array("type"=>"select","options"=>$options,"label"=>"","empty"=>"-Select-"));
    ?>
    <h2 class="module_title state_field_title"><?php echo __("Select State");?></h2>
    <?php
    //$options = ListingFieldProperties::getStateOptions();
    $options = array();
    echo $form->input(ListingFieldProperties::STATE_FIELD,array("type"=>"select","options"=>$options,"label"=>"","empty"=>"All"));
    ?>
    <div id='state_city_search_animation_div'></div>
    <h2 class="module_title city_field_title"><?php echo __("Select City");?></h2>
    <?php
    $options = array();

Link to comment
https://forums.phpfreaks.com/topic/292180-array-value/
Share on other sites

Looks like it could be CakePHP.

 

If so, would put this:

$options = ListingFieldProperties::getCountriesOptions();

in the controller:

$this->set('countries', ListingFieldProperties::getCountriesOptions());

 

and set the default in the controller as well:

$defaultCountry = /* whatever the ID of USA is */;

 

So you end up with this in the view:

echo $form->input(ListingFieldProperties::COUNTRY_FIELD,array("type"=>"select","options"=>$countries,"label"=>"","default"=>$defaultCountry));

Link to comment
https://forums.phpfreaks.com/topic/292180-array-value/#findComment-1495361
Share on other sites

Yes, it is cakephp,unfortunitly I cannot code PHP but I understand how it works and can figure out changes based on other code. I will give it a try. I am assuming the controller is in the cake folder. Thankyou for your replies.

 

Tim

Edited by thefirstone
Link to comment
https://forums.phpfreaks.com/topic/292180-array-value/#findComment-1495429
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.