Advertisement
Guest User

Untitled

a guest
Sep 21st, 2014
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * Module to prepopulate season price list with rooms
  5. */
  6.  
  7. /**
  8. * Implements hook_form_FORM_ID_alter(&$form, &$form_state)
  9. */
  10.  
  11. function mymodule_form_seasonal_prices_node_form_alter(&$form, &$form_state){
  12.  
  13. // Load all of the room node ids into an array
  14. $node_type = "room";
  15. $result = db_query("SELECT nid FROM node WHERE type = '%s' ", $node_type);
  16. $nids = array();
  17. while ($obj = db_fetch_object($result)) {
  18. $nids[] = $obj->nid;
  19. }
  20.  
  21. // Set the form state to include each room
  22. foreach($nids as $nid){
  23. $form_state->field_collection_you_want_to_edit[] = $nid
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement