CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • Altering event name field on Search form
Pages: [1]

Author Topic: Altering event name field on Search form  (Read 400 times)

jimurl

  • I post occasionally
  • **
  • Posts: 70
  • Karma: 0
  • CiviCRM version: 3.4.6
  • CMS version: drupal 6.22
  • MySQL version: 5+
  • PHP version: 5+
Altering event name field on Search form
April 13, 2012, 11:21:46 am
Hello,

I am working on the 'Event Name' field used in several search pages- like the Advanced search CiviEvents pane, and the 'Find Participants' search page.

On these search forms, the "Event Name" and "event type" fields are autocomplete text boxes. We only have about 20 events at any one time, and only two different event types, so dropdown lists are more appropriate.

I tried to edit the template file where this is displayed, Event/Form/Search/Common.tpl  I changed this:
Code: [Select]
{$form.event_name.html|crmReplace:class:huge}
into this:

Code: [Select]
      <select name ='event_name' type="select" id="event_name" class="form-text">
      <option value =''>-Any-</option>
      {crmAPI var="EventS" entity="Event" action="get" version="3" is_active="1" }
        {foreach from=$EventS.values item=Event}

          <option value ='{$Event.id}'
            {if $Event.event_title  == $form.event_name.value}
              selected = 'selected'
            {/if}
          >{$Event.event_title}</option>
        {/foreach}
    </select>

It mostly worked. It worked fine to search for participants; but when the search form is rebuilt, it doesn't default to the event choosen on the previous search page; so if users go directly to the 'Actions' menu to perform an action, they are actually performing that action a different search, search results  which include contacts from all events.

In my code above, the {if $event title == $event_name } then "selected = selected"
was supposed to fix this, but doesn't work. I found that the $form variable includes a hidden "event_id" form element, which is properly populated in the autocomplete form field, but not in my dropdown form.

It works fine, actually, if the user re-selects the event; but its a pretty easy step to forget, and we have done it several times!

Then I started to think, there must be a better way to do this ... in Search.php for example? but could not find where the input field type is set.

Any ideas?

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • Altering event name field on Search form

This forum was archived on 2017-11-26.