Difference between setValues() and addValues()
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
1
down vote
favorite
In magento module for the back-end part, for admin form edit tab we are using addValues() and setValues().I want to know difference between those 2 functions
magento2
add a comment |Â
up vote
1
down vote
favorite
In magento module for the back-end part, for admin form edit tab we are using addValues() and setValues().I want to know difference between those 2 functions
magento2
In simple termsetValues
reset the value andaddValue
append the value
â Murtuza Zabuawala
41 mins ago
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
In magento module for the back-end part, for admin form edit tab we are using addValues() and setValues().I want to know difference between those 2 functions
magento2
In magento module for the back-end part, for admin form edit tab we are using addValues() and setValues().I want to know difference between those 2 functions
magento2
magento2
asked 1 hour ago
Charvi Parikh
43829
43829
In simple termsetValues
reset the value andaddValue
append the value
â Murtuza Zabuawala
41 mins ago
add a comment |Â
In simple termsetValues
reset the value andaddValue
append the value
â Murtuza Zabuawala
41 mins ago
In simple term
setValues
reset the value and addValue
append the valueâ Murtuza Zabuawala
41 mins ago
In simple term
setValues
reset the value and addValue
append the valueâ Murtuza Zabuawala
41 mins ago
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
You can find both function's definitions in file vendormagentoframeworkDataForm.php
.
public function setValues($values)
foreach ($this->_allElements as $element)
if (isset($values[$element->getId()]))
$element->setValue($values[$element->getId()]);
else
$element->setValue(null);
return $this;
The setValues($values)
function set values according to the array passed in it and set null
for the keys which are not set.
Where addValues($values)
function does the first part only means it only sets the keys which are available.
public function addValues($values)
if (!is_array($values))
return $this;
foreach ($values as $elementId => $value)
$element = $this->getElement($elementId);
if ($element)
$element->setValue($value);
return $this;
Thank you very much
â Charvi Parikh
1 hour ago
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
You can find both function's definitions in file vendormagentoframeworkDataForm.php
.
public function setValues($values)
foreach ($this->_allElements as $element)
if (isset($values[$element->getId()]))
$element->setValue($values[$element->getId()]);
else
$element->setValue(null);
return $this;
The setValues($values)
function set values according to the array passed in it and set null
for the keys which are not set.
Where addValues($values)
function does the first part only means it only sets the keys which are available.
public function addValues($values)
if (!is_array($values))
return $this;
foreach ($values as $elementId => $value)
$element = $this->getElement($elementId);
if ($element)
$element->setValue($value);
return $this;
Thank you very much
â Charvi Parikh
1 hour ago
add a comment |Â
up vote
3
down vote
accepted
You can find both function's definitions in file vendormagentoframeworkDataForm.php
.
public function setValues($values)
foreach ($this->_allElements as $element)
if (isset($values[$element->getId()]))
$element->setValue($values[$element->getId()]);
else
$element->setValue(null);
return $this;
The setValues($values)
function set values according to the array passed in it and set null
for the keys which are not set.
Where addValues($values)
function does the first part only means it only sets the keys which are available.
public function addValues($values)
if (!is_array($values))
return $this;
foreach ($values as $elementId => $value)
$element = $this->getElement($elementId);
if ($element)
$element->setValue($value);
return $this;
Thank you very much
â Charvi Parikh
1 hour ago
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
You can find both function's definitions in file vendormagentoframeworkDataForm.php
.
public function setValues($values)
foreach ($this->_allElements as $element)
if (isset($values[$element->getId()]))
$element->setValue($values[$element->getId()]);
else
$element->setValue(null);
return $this;
The setValues($values)
function set values according to the array passed in it and set null
for the keys which are not set.
Where addValues($values)
function does the first part only means it only sets the keys which are available.
public function addValues($values)
if (!is_array($values))
return $this;
foreach ($values as $elementId => $value)
$element = $this->getElement($elementId);
if ($element)
$element->setValue($value);
return $this;
You can find both function's definitions in file vendormagentoframeworkDataForm.php
.
public function setValues($values)
foreach ($this->_allElements as $element)
if (isset($values[$element->getId()]))
$element->setValue($values[$element->getId()]);
else
$element->setValue(null);
return $this;
The setValues($values)
function set values according to the array passed in it and set null
for the keys which are not set.
Where addValues($values)
function does the first part only means it only sets the keys which are available.
public function addValues($values)
if (!is_array($values))
return $this;
foreach ($values as $elementId => $value)
$element = $this->getElement($elementId);
if ($element)
$element->setValue($value);
return $this;
answered 1 hour ago
Knight017
11311
11311
Thank you very much
â Charvi Parikh
1 hour ago
add a comment |Â
Thank you very much
â Charvi Parikh
1 hour ago
Thank you very much
â Charvi Parikh
1 hour ago
Thank you very much
â Charvi Parikh
1 hour ago
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f245638%2fdifference-between-setvalues-and-addvalues%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
In simple term
setValues
reset the value andaddValue
append the valueâ Murtuza Zabuawala
41 mins ago