Closed (fixed)
Project:
Drupal core
Version:
7.15
Component:
field system
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
11 Oct 2012 at 21:40 UTC
Updated:
15 Jun 2018 at 13:06 UTC
Jump to comment: Most recent
Comments
Comment #1
malcomio commentedNot really sure what you're trying to achieve, but if you're working with forms, you should read http://drupal.org/node/751826
If you want to change values based on the form submission, then you can work with the Field API in your form submit handler.
Comment #2
miteshmapI was saying that. there was a method with cck in drupal 6 to attach a cck field in our custom form. like.
So how can i do the same with drupal 7 ?? I had a form and i want to use the field that i created for a node type.
Comment #3
Anonymous (not verified) commentedHave you looked at the Field API documentation as suggested? Maybe using field_view_field() is what you want?
Comment #4
miteshmapYes, I checked that but its not helpfull. what i need is something like this.
Please let me know if its not clear.
Comment #5
Anonymous (not verified) commentedhttp://api.drupal.org/api/drupal/modules%21field%21field.attach.inc/func...
Comment #6
miteshmapI also tried this . but it didn't work as i don't have any "$entity" to pass in function, also the view mode should be form to display it like a form element which is not supported here. i guess..........
Comment #7
Anonymous (not verified) commentedThe entity is node. You stated it in your original post.
Comment #8
manjeet commentedfunction drupal_form(){
.
.
.
module_load_include('inc', 'field_ui', 'field_ui.admin');
$entity_type = 'node';
$field_name = 'field_name';
$field = field_info_field($field_name);
$instance = field_info_instance($entity_type, $field_name, $node->type);
$form += field_ui_default_value_widget($field, $instance, $form, $form_state);
.
.
return $form;
}
Comment #9
dimetry commented@manjeet Thanks! It works
Comment #10
sanju1092101 commentedMarking it as fixed as per comment in #8.
Thanks
Comment #12
MarX commentedThank you very much ;-)