Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
By spyout98 on
I developed a module that create, with field api, a custom field in order to be used in content types. It's similar to link module (https://drupal.org/project/link), because I create a custom field to be used in content types.
I'm developing now a module that have a custom form, that I built with hook_form. I wanna know how do I reference in my form, the field I had created in other module?
Do I have to use some hook or drupal function? I dont know what to do.
Simplifing, How do I insert my custom field (created in other module) in my custom form?
Thanks!
I'm using Drupal 7.
Comments
The form API uses form
The form API uses form elements defined with hook_element_info(). This is different that fields defined using the field API.
The form API uses form
The Field API also uses form elements defined with hook_element_info().
You cannot use Field API
You cannot use Field API elements in your form. However, you can create a form then tie into the Field API in the submission. Why don't you tell us more about what you are trying to do, as you haven't provided enough information yet to be able to explain. Why do you want to use a Field in your form? Please give a longer more detailed explanation about your overall goals etc.
Add an existing entity field to my custom form
Following code to add existing entity in the custom form.
If the entity field is field_collection_item then we can use this one.
If the entity field is user form
If the field is certain content type
You are genius! Thank you a
gaja_daran You are genius! Thank you a lot! That worked!
Thank you!
Work for me ! Last...How can I save the values in database?
Cheers.