Closed (outdated)
Project:
TableField
Version:
7.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
2 Oct 2011 at 09:09 UTC
Updated:
22 Dec 2025 at 20:34 UTC
Jump to comment: Most recent
Comments
Comment #1
kevin hankens commentedHave a look at hook_form_alter(). That will let you handle the validation part. The autocomplete might be a little harder, but still achievable. Probably easiest with a jQuery snippit.
Comment #2
infiniteluke commentedI need to validate that cell values are floats, that part was easy. Though, what I'm not sure about is how to get form_set_error to highlight the offending cell and only that cell. Currently entering form_set_error('field_breakdown_table', ....) highlights all cells, obviously. I've tried crazy things like
"'field_breakdown_table']['widget']['default_value'][0]['tablefield']['cell_" . $row . "_" . $column . "'"
but haven't seen anything work yet. Is this even possible?
Let me know if you need more info. Thanks!
Comment #3
infiniteluke commentedI posted the solution I found for #2 in the form_set_error documentation.
Comment #4
mouthofthesea commentedHi, I found very helpful this documentation and thanks to all for the suggestions.
Now I try to set the following code:
function _form_alter(&$form, &$form_state, $form_id) {
//DEBUG VALUES
dsm($form_id);
dsm($form);
//FORM VALIDATION
form_set_error('][0][tablefield][cell_' . $row . '_' . $column, t('Value at row @row, column @column is not valid.', array('@row' => $row, '@column' => $column)));
}
But in the edit page i got this:
"Error message - Value at row , column is not valid."
Even if I change the $row and the $column variable to a fixed value.
Something goes wrong on my approach....
Any suggestions will be much appreciate.
Thanks in advance.
Best regards.
Comment #5
mouthofthesea commentedHi to all,
After a proper investigation, I'd miss the approach on how to Drupal handle the validation form.
Now I'm able to run the custom validation on a single cell value.
Best.
Comment #6
lolandese commentedComment #7
lolandese commentedComment #8
lolandese commentedComment #9
liam morlandDrupal 7 is no longer supported. If this applies to a supported version, please re-open.