Skip to content

Commit e7c109d

Browse files
committed
Fix a bug with the multipleSelect selector
1 parent 5326c40 commit e7c109d

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
### Upgrade
2+
- If you are upgrading from v2.0, v2.1, v2.2, v2.3 to v2.4 make sure you publish the vendor resource. There are some updates to the config file.
23
- If you are upgrading from v2.0, v2.1 or v2.2 to v2.3 make sure you publish the vendor resource. There are some updates to the config file.
34
- If you are upgrading from v2.0 or v2.1 to v2.2 make sure you publish the vendor resource. There are some changes to the templates that required to be updated.
45
-- If you are upgrading any version prior v2.2 follow the upgrate instruction on https://crestapps.com/laravel-code-generator/docs/2.2#upgrade-guide

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "crestapps/laravel-code-generator",
33
"license": "MIT",
44
"description": "A clean code generator for Laravel framework that will save you time! This awesome tool will help you generate resources like views, controllers, routes, migrations, languages or request-forms! It is extremely flexible and customizable to cover many use cases. It is shipped with cross-browsers compatible template, along with a client-side validation to modernize your application.",
5-
"version": "v2.2.3",
5+
"version": "v2.2.4",
66
"keywords": [
77
"laravel","crud","crud generator",
88
"laravel crud generator","laravel crud builder",

config/codegenerator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@
252252
'password' => 'Enter [% field_name %] here...',
253253
'email' => 'Enter [% field_name %] here...',
254254
'select' => 'Select [% field_name %]',
255+
'multipleSelect' => 'Select [% field_name %]',
255256
],
256257

257258
/*

src/HtmlGenerators/LaravelCollectiveHtml.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ protected function getMultipleRawOptionValue($name, $value, $defaultValue)
229229
$modelVariable = $this->getSingularVariable($this->modelName);
230230
$valueString = 'null';
231231
if (!is_null($value)) {
232-
$valueString = starts_with('$', $value) ? sprintf("%s", $value) : sprintf("'%s'", $value);
232+
$valueString = starts_with($value, '$') ? sprintf("%s", $value) : sprintf("'%s'", $value);
233233
}
234234
$defaultValueString = '[]';
235235
if (!empty($defaultValue)) {
@@ -273,7 +273,7 @@ protected function getDefaultValueAccessor($modelVariable, $property, $value)
273273
*/
274274
protected function getMultipleSelectedValue($name, $valueAccessor, $defaultValue)
275275
{
276-
return sprintf(" (%s ? true : null) ", $name);
276+
return sprintf(" (%s ? true : null) ", $this->getMultipleRawOptionValue($name, $valueAccessor, $defaultValue));
277277
}
278278

279279
/**

src/HtmlGenerators/StandardHtml.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ protected function getFieldPlaceHolderForMenu(Label $placeholder = null, $name =
112112
*/
113113
protected function getFieldMultiple($isMulti)
114114
{
115-
return $isMulti ? 'multiple="multiple"' : '';
115+
return $isMulti ? ' multiple="multiple"' : '';
116116
}
117117

118118
/**
@@ -188,6 +188,7 @@ protected function getCheckedItem($value, $name, $defaultValue)
188188
*/
189189
protected function getMultipleCheckedItem($value, $name, $defaultValue)
190190
{
191+
191192
return sprintf(" {{ %s ? 'checked' : '' }}", $this->getMultipleRawOptionValue($name, $value, $defaultValue));
192193
}
193194

@@ -226,7 +227,7 @@ protected function getDefaultValueAccessor($modelVariable, $property, $value)
226227
*/
227228
protected function getMultipleSelectedValue($name, $valueAccessor, $defaultValue)
228229
{
229-
return sprintf(" {{ %s ? 'selected' : '' }}", $name);
230+
return sprintf(" {{ %s ? 'selected' : '' }}", $this->getMultipleRawOptionValue($name, $valueAccessor, $defaultValue));
230231
}
231232

232233
/**
@@ -277,7 +278,7 @@ protected function getMultipleRawOptionValue($name, $value, $defaultValue)
277278
$valueString = 'null';
278279

279280
if (!is_null($value)) {
280-
$valueString = starts_with('$', $value) ? sprintf("%s", $value) : sprintf("'%s'", $value);
281+
$valueString = starts_with($value, '$') ? sprintf("%s", $value) : sprintf("'%s'", $value);
281282
}
282283

283284
$defaultValueString = '[]';

0 commit comments

Comments
 (0)