Closed (fixed)
Project:
Link
Version:
7.x-1.0
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
12 Sep 2012 at 15:55 UTC
Updated:
18 Jun 2013 at 15:35 UTC
We have a custom module using hook_form_alter which sets the default values of fields in a content type, the code below which works for other fields doesn't work for the link field.
$form['field_company_name']['und'][0]['value']['#default_value'] = $value;
we tried using ['url'] instead of ['value'] but this doesn't seem to work.
Can someone please help with this.
Comments
Comment #1
iajay commentedhttp://drupal.org/node/1647770 this might help
Comment #2
ghaddon commentedThanks for the reply but unfortunately still cant get it to work
<input id="edit-field-company-website-und-0-url" class="form-text" type="text" maxlength="2048" size="60" value="" name="field_company_website[und][0][url]">I have tried all the following code but to no avail.
$form['field_company_website']['und'][0]['url']['#default_value']['url'] = 'http://www.example.com' ;$form['field_company_website']['und'][0]['#default_value']['url'] = 'http://www.example.com' ;$form['field_company_website']['und'][0]['url']['#default_value'] = 'http://www.example.com' ;$form['field_company_website']['und'][0]['#default_value'] = 'http://www.example.com' ;$form['field_company_website']['und'][0]['value']['url']['#default_value']['url'] = 'http://www.example.com' ;$form['field_company_website']['und'][0]['url']['value']['#default_value']['url'] = 'http://www.example.com' ;$form['field_company_website']['und'][0]['value']['url']['#default_value'] = 'http://www.example.com' ;$form['field_company_website']['und'][0]['url']['value']['#default_value'] = 'http://www.example.com' ;$form['field_company_website']['und'][0]['value']['#default_value']['url'] = 'http://www.example.com' ;$form['field_company_website']['und'][0]['value']['#default_value'] = 'http://www.example.com' ;Comment #3
ghaddon commentedMy bad fixed it with the following method
$form['field_company_website']['und'][0]['#default_value']['url']Comment #4
ghaddon commentedComment #5
ghaddon commentedComment #5.0
ghaddon commentedforgot to say please