[CLOSED] Form validation including form on user control

  1. #1

    [CLOSED] Form validation including form on user control

    We have a <ext:FormPanel> which includes a <ext:Panel> which includes a user control. The user control has a grid and a form which the user enters to add a new row into the grid. The form on the user control has 2 required fields - but they are only required for the "Add" function into the grid. They should not affect the validation of the outer form panel.

    Psuedo code for the form panel layout:
    <ext:FormPanel id='fred'>
      .......form widgets here.
         <ext:Panel>
              <ext:PartialRender.....user control......../>
         </ext:Panel>
    
    .....form widgets here
    </ext:FormPanel>
    Psuedo code for the user control:
       <ext:Panel...
              <ext:GridPanel.....</ext:GridPanel>
              <ext:FormPanel>
                     <ext:TextField.....Last name - required/>
                     <ext:Button .... add button - adds to the grid/>
              </ext:FormPanel>
    
       </ext:Panel>
    So if I test 'fred'.isValid() it will say false because of the required fields on the form panel in the user control. I want to be able to exclude the user control from the isValid(). The prior version 1.x did not do this.

    I am upgrading from 1.x to 2.5 and found this issue. I do not want to have to redo the entire layout by putting a form around each set of widgets on the page that are not a user control to validate the parent form.

    Thanks,
    Last edited by Daniil; Sep 26, 2014 at 12:17 PM. Reason: [CLOSED]
  2. #2
    Hi @jbarbeau,

    A FormPanel cascades all the items on validation. It works in the same way in both - v1 and v2. If something is rendered to a FormPanel as Items, I would say that there is no a built-in way to exclude that from the FormPanel's validation functionality.

    If it works with v1, it probably means that the user control's content is rendered as <Content>, not as <Items>. So, the user control's content doesn't participate in validation of the outer FormPanel. So, we could try to get the same in v2.

    Does this Panel have any Layout setting? If yes, please try to remove.
    <ext:Panel>
         <ext:PartialRender.....user control......../>
    </ext:Panel>
    What is <ext:PartialRender> by the way? Is it inside the Panel's Items? If so, please try to put to Content instead.
  3. #3

    ExtPartial-

     <ext:Panel runat="server" Border="true" ID="EnterOrderPP">
                                     <Content>
                                        <%= Html.ExtPartial(MVC.Orders.Shared.Views.ProtectedPersonsList, mode: RenderMode.AddTo, items: true, idMode: Ext.Net.IDMode.Predictable, model: this.Model.ProtectedParties, viewData: new ViewDataDictionary(this.Model.ProtectedParties), containerId: "EnterOrderPP")%> 
                                     </Content>
                                </ext:Panel>
    So it is using the <Content> tag and shouldn't pick it up right?
  4. #4
    No. With these settings
    mode: RenderMode.AddTo, items: true
    it will be still rendered as items.

    You can removed those settings and change
    containerId: "EnterOrderPP"
    to
    containerId: "EnterOrderPP-innerCt"
    then the partial view will be rendered as raw HTML content, not as items.

    After that the inner FormPanel should not affect the outer FormPanel.

    Though, you might get some changes in the layout, because the partial view won't participate in the Ext.NET layout anymore.

    Personally, I would think about redesign. I mean that it is rather a design problem. If an inner FormPanel should not affect its outer FormPanel, then it should be, in my opinion, outside.
  5. #5

    Did not work

    The user controls would not display at all if I did that. What I ended up doing is wrapping the widgets between the user controls into 3 seperate forms then testing validation on that.

    I do disagree with your opinion that this is a design flaw. The user control should be able to be used in multiple places (hence why it is a user control) and the form on the user control only needs to validate when someone is adding a new row to the grid in the user control - not when the form the control is on is being validated.

    Thanks,
  6. #6
    Ok, it might be controversial.

    In any way, it is nice to hear that you were able to resolve the problem.

Similar Threads

  1. Replies: 0
    Last Post: Jul 02, 2013, 5:32 AM
  2. [CLOSED] Is it possible to control child form controls from main form?
    By rnachman in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Aug 13, 2012, 12:24 PM
  3. [CLOSED] cross-window form validation with focus on an invalid control
    By ViniVidi in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Aug 18, 2011, 4:51 PM
  4. [CLOSED] Form Validation within template of a asp:login control
    By ljcorreia in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Nov 27, 2009, 12:15 PM
  5. Replies: 1
    Last Post: Feb 10, 2009, 1:30 PM

Posting Permissions