Closed (fixed)
Project:
Link
Version:
7.x-1.0
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
19 Jun 2012 at 18:12 UTC
Updated:
18 Jun 2013 at 15:34 UTC
The link field seems to work fine without a default value:
<input id="edit-field-fieldgroup-und-0-field-web-site-link-und-0-url" class="fluid form-text" type="text" maxlength="2048" size="" value="" name="field_fieldgroup[und][0][field_web_site_link][und][0][url]">
But when I use a hook_form_alter() to set a default value, the form field breaks:
<?php
$form['field_fieldgroup']['und'][0]['field_web_site_link']['und'][0]['#default_value'] = 'http://www.example.com';
?>
The size is blank and the value only has the first character:
<input id="edit-field-fieldgroup-und-0-field-web-site-link-und-0-url" class="fluid form-text" type="text" maxlength="2048" size="" value="h" name="field_fieldgroup[und][0][field_web_site_link][und][0][url]">
Comments
Comment #1
stevenc commentedThis field has sub-components, so you need to set the 'url' index for it:
Comment #2
ghaddon commentedI am also having a similar problem with adding a default value.
http://drupal.org/node/1782516
<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.
If you found a solution it would be greatly appreciated
Comment #3
ghaddon commentedI fixed the problem
$form['field_company_website']['und'][0]['#default_value']['url'] = "url"Thanks
Comment #4
ghaddon commented