mardi 30 juin 2015

Drupal Customized Editable View

This one's a doozy. I'm working on a project where we want to be able to create a record, select a group of users and send an email to them directly from Drupal. I'm having trouble figuring out how to do this.

First, I want to be able to create a new record and populate a few fields. So this would be a custom content type or entity. Let's say I'm calling it EMAIL NODE. Here I'd set the title, the email subject and body. The catch is I want to see a table of all the registered users with some fields such as first name, last name, email address, company, etc. It has to be sortable and filterable. Normally I'd use a view to achieve this. I guess an embedded view using hook_form_alter to get it in the edit form.

The catch is that each user row also needs to have a few checkboxes such as Opt In, Opt Out, and Viewed. I need to able to update these checkboxes so that I can manually change any of their states. I also need to be able to select one or more rows then click a button to send them an email. The values of each checkbox should be retained in the EMAIL NODE record.

I can't think of any way to do this using off the shelf modules. I know there's an editable view module, but that assumes I'm editing existing records. In my case all the user's exist, but the state of each checkbox doesn't exist until I create the EMAIL NODE.

I think the only way to do it is a custom module that leverages hook_form_alter to insert the view and uses some javascript to save the state of each checkbox. Maybe use some hidden fields and comma separated UIDs to store the states of each checkbox. When the page loads it parses the fields and based on the UID modifies the state of the checkboxes.

Is there an easier way or is this just a very customized scenario?

Thanks, Howie




Aucun commentaire:

Enregistrer un commentaire