datadoit
|
Posted: 01/07/2011, 8:25 AM |
|
I find that I have to do this a lot...
For a data entry record form, if I have an input field where I need to
retrieve a default value for it, the Retrieve Value for Control action
works great.
However, if anywhere on the record form there's a data validation error,
then the value that the user may have changed in that input field will
get overwritten with the Retrieve Value for Control action again. A
real simple fix for this would be to add a conditional 'is null'
property parameter to the Retrieve Value for Control action.
Control Name: MyControl
Source Type: Expression
Source Name: "Mary had a little lamb"
Is Null: True
Would create this code:
if (CCStrLen($Component->GetText()) < 1) {
$Container->MyControl->SetValue("Mary had a little lamb");
}
If the 'Is Null' is set to False, then the condition would be removed.
The same could be applied to the DLookup action. Only do it if the
field control value is null.
|
|
|
datadoit
|
Posted: 01/31/2011, 4:41 PM |
|
Discovered that with PHP ternary logic can be used in the Retrieve Value
for Control action.
Control Name: My Control
Source Type: Expression
Source Name: (CCStrLen($Component->GetText()) < 1) ?
$Component->SetValue("Mary had a little lamb") : $Component->GetValue()
|
|
|
|