Hi
I wanna know how could I set the ability to validate empty fields on a table field of a node type on it's create mode; I mean how could I let the administrator of my site to set validation(e.g. required) of each cell of a table field.

And my second question is does it possible for me to get the ability to the administrator of my site to assign a cell auto completed from other cells? for example aggregate cell 1 & 2 and show the sum value on cell 3.

If there is possibilities for our request, how could I do that & if not how could I do it because I'm a asp.net developer & newbie to drupal.

Thanks

Comments

kevin hankens’s picture

Have 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.

infiniteluke’s picture

I 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!

infiniteluke’s picture

I posted the solution I found for #2 in the form_set_error documentation.

mouthofthesea’s picture

Issue summary: View changes

Hi, 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.

mouthofthesea’s picture

Hi 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.

lolandese’s picture

Assigned: jerzi.net » Unassigned
lolandese’s picture

Priority: Major » Normal
lolandese’s picture

Version: 7.x-2.0-beta4 » 7.x-3.x-dev
liam morland’s picture

Status: Active » Closed (outdated)

Drupal 7 is no longer supported. If this applies to a supported version, please re-open.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.