I am using Drupal 7 and have figured out the text fields and a taxonomy dropdown but having no luck with an address field picking a state or country. my content type is directory-listing
the url below doesn't work -- but for a taxonomy dropdown the same logic works (using the "name" attribute and the value)
http://MY DOMAIN NAME.com/node/add/directory-listing?edit[field_address][und][0][administrative_area]=AK
-html...
select id="edit-field-address-und-0-administrative-area" class="state form-select" size="0"
name="field_address[und][0][administrative_area]">
<option selected="selected" value="">--</option>
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
more options....
for the radio buttons I have (content type testing)
http://my domain/node/add/testing?edit[field_my_radio][und]=1 (doesn't work)
<div class="form-item form-type-radios form-item-field-my-radio-und">
<label for="edit-field-my-radio-und">my radio </label>
<div id="edit-field-my-radio-und" class="form-radios">
<div class="form-item form-type-radio form-item-field-my-radio-und">
<input id="edit-field-my-radio-und-none" class="form-radio" type="radio" value="_none" name="field_my_radio[und]">
<label class="option" for="edit-field-my-radio-und-none">N/A </label>
</div>
<div class="form-item form-type-radio form-item-field-my-radio-und">
<input id="edit-field-my-radio-und-1" class="form-radio" type="radio" value="1" name="field_my_radio[und]">
<label class="option" for="edit-field-my-radio-und-1">One </label>
</div>
<div class="form-item form-type-radio form-item-field-my-radio-und">
<input id="edit-field-my-radio-und-2" class="form-radio" type="radio" value="2" name="field_my_radio[und]">
<label class="option" for="edit-field-my-radio-und-2">Two </label>
</div>
Comments
Comment #1
cimo75 commented+1 for radio buttons
Comment #2
mototribe commentedI don't think prepopulate will work with address field because the way the "address" array is structured:
You can prefill it in a hook_form_alter() with something like:
$form['field_address'][LANGUAGE_NONE][0]['#address']['country'] = 'US';
$form['field_address'][LANGUAGE_NONE][0]['#address']['locality'] = 'Livermore';
$form['field_address'][LANGUAGE_NONE][0]['#address']['administrative_area'] = 'CA';
$form['field_address'][LANGUAGE_NONE][0]['#address']['postal_code'] = '94551';
Comment #2.0
mototribe commentedadded
Comment #3
rbrownellAny movement on this? Surely prepopulate can adapt the the array structure.
EDIT: I have given up on this module instead opting to use a combination of Rules and Rules Links to achieve the same functionality.
Comment #4
nodecode commented@rbrownell is there any wisdom you can share about using rules to prepopulate address fields? I'm experimenting with a combination of these modules: rules + pathrules + rules_url_argument.
I'm able to get Rules to recognize a url argument and use it as a variable. But I'm stuck trying to get Rules to interact with my form. I'm using "Execute Custom PHP code" because I assume this is the only way to alter the form. Can you share any code or give us a basic rundown of your method?
Thank you in advance for your contribution
Comment #5
scuba_flyHaving this issue, I created a patch for this.
Using this patch you can add the value like so:
edit[field_training_festival][und]=710If the output of your field was like so
Removed the labels to make the output a bit more clean.
Comment #6
dbazuin commentedI added Prepopulate to a site and tried to use it on a list field.
When I tried to use ?edit[field_lijstje][und]=c the field still had the default value.
After I applied "prepopulate-add-radios-1424774-5.patch" the value of the field changed to c.
So +1 for this patch.