Jump to content

Search the Community

Showing results for tags 'selected'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

Found 3 results

  1. Hi all, I have need to dynamically set InputFieldMultiSelect to selected on page load based on the status of some items within a database table. However I keep running into issues when trying to do this via InputfieldSelect::setOptionAttributes() https://processwire.com/api/ref/inputfield-select/set-option-attributes/ Going by the above it sounds like it should be pretty straight forward, and for certain values it seems to work but not when I wanted to set it to 'selected'. For example: $f->setOptionAttributes(1030,['foo' => 'test']); The above works as I would have wanted, in that it updates the option with the value 1030, to include the attribute foo="test" But the same code above edited to the following: $f->setOptionAttributes(1030,['selected' => 'selected']); Doesn't seem to do anything? I assume I'm missing something or trying to implement the 'selected' wrongly but I'm not sure how else I should approach this, any advice would be much appreciated.
  2. I've been trying to make a carousel with a repeater field that has an "active" class on the first div. I found a similar thread here but still can't get it to work. Most likely me having a dumb moment Here's my code: <div class="carousel slide <?=$page->position?>"> <h4><?=$page->heading?></h4> <!-- Carousel items --> <div class="carousel-inner"> <?php $output = ''; $class = 'item'; foreach($page->testimonials as $testimonial) { $status = ''; if ($testimonial === $page->testimonials->first()) $status .= ' active'; $class .= $status; $output .= "<div class='{$class}'> <img class='quotes' src='{$config->urls->templates}assets/img/quotes.png'> <p>{$testimonial->body}</p> <h6>{$testimonial->person_name}</h6> </div>"; } echo $output; ?> </div> </div> Any ideas where I'm going wrong?
  3. Hi all, Hope for a helpful hint and thank you in advance. I am trying to create a form in the frontend with custom markup for the form and the fields. Its all fine, except that I cant find out 1. how to remove the empty "<option></option>" choice and 2. I was wandering if there is a smarter way of making one of the options "selected" in page field using select inputfield. Here is my code: $newPage = new Page(); $newPage->template = 'my_weather'; $field = $fields->get('temp_units'); $inputfield = $field->getInputfield($newPage); $select = $inputfield->getInputfield(); $options = $select->getOptions(); foreach ($options as $key => $val){ $select->removeOption($key); } foreach ($options as $key => $val){ $attr = ($val == 'kg') ? array('selected' => 'selected') : null; $select->addOption($key, $val, $attr); } echo $select->render(); Of course, I could skip render() and output my markup with the options above instead, but it is a quite large form and I prefer to know if this is the right way of getting things done with the API. Thanks!
×
×
  • Create New...