Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug-in-checkbox #1252

Open
trob opened this issue May 27, 2014 · 8 comments
Open

bug-in-checkbox #1252

trob opened this issue May 27, 2014 · 8 comments

Comments

@trob
Copy link

trob commented May 27, 2014

http://www.fabrikar.com/forums/index.php?threads/bug-in-checkbox.38663/
array_key_exists($element->name, $data) does exist in case of "no checkbox checked"
["checkbox"]=> string(0) ""
["checkbox_raw"]=> NULL

so I think line 119 checkbox.php has to be
if (!array_key_exists($element->name, $data)||$data[$element->name]=="")

This is working but I'm not sure about
$data[$element->name] = $params->get('sub_default_value');
$data[$element->name . '_raw'] = array($params->get('sub_default_value'));

why without/with array?

@s6930064
Copy link

s6930064 commented Aug 7, 2014

any news about this ?

@cheesegrits
Copy link
Member

I'm not convinced there's a problem. See thread for my response.

@trob
Copy link
Author

trob commented Sep 13, 2014

The "Defaults" tooltipps are saying "Data to record if no checkbox is ticked"/"Text shown in table view if..."
So I would say the default value should be recorded (analog to dbjoin "please select")

I can see the mismatch in the definition to a standard element "Default".

@cheesegrits
Copy link
Member

Hmmm. I'm not sure why the tool tip says that. Afaik, the checkbox has
never behaved that way, and the default has always behaved like any other
element. It's the value used when a new form is first displayed.

It's possible that the tool tip was copied from the radio button, as they
behave differently, in that a radio group should always have a selected
value.

So, I guess we have to decide whether to change the behaviour, or the tool
tip. I'd rather not change the behavior, as I can see that affecting a lot
of other sites, that rely on the existing behaviour.
On Sep 13, 2014 6:23 AM, "troester" notifications@github.com wrote:

The "Defaults" tooltipps are saying "Data to record if no checkbox is
ticked"/"Text shown in table view if..."
So I would say the default value should be recorded (analog to dbjoin
"please select")

I can see the mismatch in the definition to a standard element "Default".


Reply to this email directly or view it on GitHub
#1252 (comment).

@trob
Copy link
Author

trob commented Sep 14, 2014

Behaviour is the same in Fabrik3.2.
I don't think changing the behaviour will be affecting existing sites because it would only change something if these additional "Defaults" settings are set.
If the "Defaults" section has no effect at all (as it is at the moment) what it is for?

@cheesegrits
Copy link
Member

My bad, I was thinking about the specific checkbox defaults.

OK, yeah ... I'll fix that.

@cheesegrits
Copy link
Member

Turns out it's not quite as simple as just tweaking that line in getEmptyDataValue(). Its going to take some changes where that method gets called, in onStoreRow():

    //if (!array_key_exists($name, $formModel->formDataWithTableName))
    if ($this->dataConsideredEmpty(JArrayHelper::getValue($formModel->formDataWithTableName, $name, '')))
    {
        $this->getEmptyDataValue($data);
    }

That commented out line is what's there at the moment, which means getEmptyDataValue() won't even get called if the key exists.

The replacement is what I'm testing, but it isn't what is needed either.

I had to move on to something else, but I'll try and get back to this soon.

@cheesegrits
Copy link
Member

Oh, and just for my own notes ... even if we call getEmptyData(), it'll need to be tweaked to NOT set the _raw value in that context, because the $data we are setting up in onStoreRow() is what gets used for the actual insert/update query, and should only conatin valid field names ... which the _raw isn't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants