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

Datagrid as component in form component - filter submit bug #728

Closed
BigOHenry opened this issue Nov 15, 2018 · 3 comments
Closed

Datagrid as component in form component - filter submit bug #728

BigOHenry opened this issue Nov 15, 2018 · 3 comments

Comments

@BigOHenry
Copy link
Contributor

BigOHenry commented Nov 15, 2018

I have a form component and inside that i am creating datagrid component. When i want to submit a form or add container with button to WebChemistry/Multiplier (its a replicator) the filter is submitted even there is no filter... After filter submit any form operation is skipped (data save, my snippets refresh, etc.)

$grid = new DataGrid();
        $this->addComponent($grid, $name);
        $grid->setStrictSessionFilterValues(false);
        $grid->setPagination(false);
        $grid->setRememberState(false);
        $grid->setAutoSubmit(false);

Any idea what to do with this bug? Or am i doing something wrong?

@martingold
Copy link

So basically you have nested forms because the datagrid itself is a form. Not sure if this behavior is indeed supported. Even HTML5 itself does not support this feature.

From top of my head, you could modify the datagrid template (you do not use filters anyway) in which you would remove the wrapping form of the datagrid.. not sure thou how that would turn out

@radekdostal
Copy link
Contributor

public static function removeFormElementsFromDatagrid(string $html): string
{
  return \Nette\Utils\Strings::replace($html, [
    '/<form\s+.*>+/' => '',
    '/<input type="hidden"\s+.*-->/' => '',
    '/<\/form>/' => ''
  ], NULL, 1);
}
{capture $grid}
  {control grid}
{/capture}
{$grid|removeFormElementsFromDatagrid|noescape}

@BigOHenry
Copy link
Contributor Author

Thank you very much. Looks like it works!

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

No branches or pull requests

3 participants