Merge pull request #119 from open-sausages/hamishs_fixes

FIX iSelectFromInputGroup not understanding bootstraps input-in-label
This commit is contained in:
Damian Mooyman 2016-07-28 17:01:55 +12:00 committed by GitHub
commit 1d5e5816f0

View File

@ -480,8 +480,14 @@ JS;
foreach($parent->findAll('css', 'label') as $option) { foreach($parent->findAll('css', 'label') as $option) {
if($option->getText() == $value) { if($option->getText() == $value) {
$input = null;
// First, look for inputs referenced by the "for" element on this label
$for = $option->getAttribute('for'); $for = $option->getAttribute('for');
$input = $parent->findById($for); if ($for) $input = $parent->findById($for);
// Otherwise look for inputs _inside_ the label
if (!$input) $input = $option->find('css', 'input');
if(!$input) throw new \InvalidArgumentException(sprintf('Input "%s" cannot be found', $value)); if(!$input) throw new \InvalidArgumentException(sprintf('Input "%s" cannot be found', $value));