Existing System:

In existing system we have module table field with feature of adding rows and columns by the users enabled with required permission.

Proposed System:
TableField Module does not have feature to allow user to add row dynamically. Therefore I have created a option to add rows dynamically without adding columns if users enabled with “To change row in tablefield” permission

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

saranya ashokkumar’s picture

FileSize
4.6 KB
lolandese’s picture

Thanks Saranya,

If you don't mind I add the link to your blog post that showcases this functionality:
http://www.unimitysolutions.com/blog/working-experience-table-field-cont...

ctrlADel’s picture

FileSize
4.16 KB

Couldn't apply the patch cleanly to the current dev version so here's an attempt at rerolling.

From what I can tell this isn't functioning quite right after the reroll. The button works on the first add but not if I click it a second time. Also rebuilding with more rows isn't working after patching.

Errors I'm seeing
Notice: Undefined index: value in Drupal\tablefield\Plugin\Field\FieldType\TablefieldItem->isEmpty() (line 199 of /var/www/docroot/modules/contrib/tablefield/src/Plugin/Field/FieldType/TablefieldItem.php)

Notice: Undefined index: rebuild in Drupal\tablefield\Element\Tablefield::processTablefield() (line 58 of /var/www/docroot/modules/contrib/tablefield/src/Element/Tablefield.php)

lolandese’s picture

Priority: Major » Normal
Status: Needs review » Needs work

Changing status based on the comments in #4.

saranya ashokkumar’s picture

FileSize
4.69 KB

Hi,

I have updated the patch and it is working fine. Please Check it.

Thanks,
Saranya.P

saranya ashokkumar’s picture

Version: 8.x-2.x-dev » 8.x-2.0-alpha1
Status: Needs work » Needs review
lolandese’s picture

lolandese’s picture

Status: Needs review » Needs work

The button works on the first add but not if I click it a second time.

Now works as expected.

Rebuilding with more rows isn't working after patching.

Still the case after adding a row with the button.

The undefined index errors seem to be solved.

saranya ashokkumar’s picture

FileSize
5.03 KB

Hi lolandese,

Thanks for your reviewing!

I have fixed the rebuild and undefined index issue and uploaded the patch.

Thanks,
Saranya.

saranya ashokkumar’s picture

Status: Needs work » Needs review

lolandese’s picture

Version: 8.x-2.0-alpha1 » 8.x-2.x-dev
Status: Needs review » Fixed

Thanks for your contribution.

One minor improvement could be to update the row number in the rebuild section after adding a row with the button.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

lolandese’s picture

This was further improved at #2909827: Only validate the tablefield when adding a new row and update row value in the rebuild section:

  • Updates the row number in the rebuild section after adding a row with the button.
  • Allows for clicking the button multiple times and adds rows accordingly.
  • Avoids a validation error on new nodes saying that xxx field is required.