sequence of error messages for required field in drupal 7 - drupal

I have a content type which has 4 CCK fields.
Field name are :
field_device_data_card_id
field_device_model
field_device_type
field_device_id
These fields are in their respective sequence.
all fields are marked as mandatory. when i click submit button without filling any data in required fields, it generate error messages for mandatory fields but the sequence of error messages are not proper.
it is displayed in following sequence ->
Device Data Card ID field is required.
Device ID field is required.
Device Model field is required.
Please select a device type.
while it should be like ->
Device Data Card ID field is required.
Device Model field is required.
Please select a device type.
Device ID field is required.
Please provide me a solution so that i can sequence the error messages.
Thanks

.. add your custom validator via hook_form_alter and:
function form_name_validate($form, &$form_state) {
$tmp_msg = drupal_get_messages('error');
// change order or modify on your own of $tmp_msg
drupal_set_message($tmp_msg,'error');
}

Related

Is there a way to reference data contained in fields on related record using formula field?

I want to display the taxcode custom field on invoice records
According to Netsuite Help, the format for the formula would be like that:
{taxcode.customfieldid}, knowing that (taxcode is the field id for the taxcode field on the lines of invoice record. customfieldid is the field id for the custom field on the TaxCode record)
PS: customfieldid is a free-text
I have tried possibilities like:
{invoice.item.taxcode.customfieldid}
{item.taxcode.customfieldid}
But I still get this error "ERROR: Field 'taxcode.customfieldid' Not Found"
how can I fix this? Can anyone provide some guidance on this issue?
Generally Netsuite will only look one level away from the record you are on.
In your case you should create a new transaction line field (say custcol_tax_extra) and source that from the taxcode so when a tax code is selected that value is pulled up onto the line.
Then your xml:
<#list record.item as item>${item.custcol_tax_extra}...

How to print Activiti workflow task's values into Alfresco Share

I have a workflow to manage employee petitions, that starts with some fields at starter form. The next task, allows a responsable user to approve or reject the initiator user's petition.
I want to show the values of starting form into the approve/reject form, so I created a custom .ftl file for every field that I want print the label and the value. Now I have hard-coded the values to the this:
My problem here, is how to get the value from the first form and print it at the second form (values that I need are where says "200€" and my name).
I'm using Alfresco Community 5.1 and his own Activiti.
Thanks.
Solution 1 : keep IDs of the fields identical in both the forms. this will make the field editable in the second form.
Solution 2 : create a process variable, set its value after the first form has been submitted. then, in the second form display the value of the process variable.

How to format email link in Drupal cck Computed Field?

I am trying to create in Drupal a cck computed field that copies an email address from a cck field in a "job post" node content type to this computed field in the "job application" node content type.
I have found the following code that works perfectly, when I paste it into the "Computed Code:" box in the cck computed field
// obtain node id from nodereference cck field that links
// the job application node to the job post node
$item_nid = $node->field_appl_position[0]['nid'];
//load and build the information from the referenced job post node
$item_node = node_load($item_nid);
$item_node = node_build_content($item_node);
//get the email address from the cck email field in the referenced job post node
$item_email = $item_node->field_job_email[0]['email'];
//copy the email address to the computed field in the job application node
$node_field[0]['value'] = $item_email;
However, when I try to send an email using the content of the computed field nothing happens. I believe this is the case because the computed field is not formatted as a mailto link. I have tried to change the parameters in the "Display Format:" box in the computed field, but have not succeeded.
Can anybody please help? Thanks!
you can use the following Drupal API function to format your link:
http://api.drupal.org/api/drupal/includes--common.inc/function/l/6
so in this case the value for your computed field would be the following:
l('Mail me', 'mailto:'.$item_email);

Error in copying the content of a cck field between 2 nodes using cck computed field

I have two content types (job_post and job_application) linked using the node reference + node reference url nodes. When I click a link in a job_post node, a new job_application node is created, so that candidates can fill out their job application. My goal is to automatically copy the content of an cck email field from the referenced job_post node to a cck email field in the job_application node.
To achieve this, I am trying to use a cck computed field, as suggested in: http://drupal.org/node/298951.
In my computed field I have placed the following code:
$node_field[0]['value'] = db_result(db_query("SELECT field_emailfieldjobpost_value FROM content_type_job_post WHERE nid=%d",$node->field_referencefieldjobapplication[0][nid]));
where the field_referencefieldjobapplication, is the node reference field in my job_application node.
In the display format box of the computed field I have:
$display = $node_field_item['value'];
I have selected the option to store it in the database as a varchar.
However, nothing seems to happen. I never see the cck field or its content both when I create or after I save a new job application (I have even tried to see it in views and failed). Any suggestion on what might be wrong?
Thanks
What I would do, is give a parameter with the link (the id of the job_post). and catch the parameter and place it in a disabled cck field.
Then write a module using the hook_node_api when a jobapplication is saved, you get the data from the job_post (using node_load) and use the data from the job-post however you want.

How do I validate a nodereference field in a custom node form in Drupal 6?

I have an autocomplete nodereference field (field_hostnamelastref) in a custom pass-node-form.tpl.php. The field references four items (last name, first name, an id #, and status) generated from tokens in an autotitle from another content type.
When entering a last name in the nodereference field, if the corresponding status for that last name is "SUSPENDED", I would like to be able to validate that field with an error message and block form submission.
This is my first attempt at writing my own validation and am not having any luck. Have tried many different ways ereg, preg-match and strpos. Below is my latest attempt:
<?php
function pass_validate($form_id,$form_values) {
$status = 'SUSPENDED';
if (strpos ($form_values['hostnamelastref'], $status)) {
form_set_error('hostnamelastref', t('The account for this person has been suspended.', array('#type' => $type->name)));
}
}
?>
Not sure if I'm even in the ball park on this. Any help much appreciated!
If you can pass the SUSPENDED information somehow to views, then you can limit the nodes one chooses in the nodereference using a view. Then nodereference will take care for validation if the user entered a node not in the list.
But I am not sure I understood your question.

Resources