Sitecore - Adding button to FormDialog - sitecore

Is it possible to add a custom button to a Sitecore FormDialog other than OkButton and CancelButton e.g. instead of this
<FormDialog Icon="cool.png" Header="A really cool header" Text="Link or un-link items" OKButton="Link" CancelButton="Close">
but something more like this
<FormDialog Icon="cool.png" Header="A really cool header" Text="Link or un-link items" OKButton="Link" UnLinkButton="UnLink" CancelButton="Close">

I don't think it is possible to add another button by passing in an attribute on the FormDialog element without modifying original the FormDialog.xml
But there is a placeholder element defined in the DialogForm control (in /sitecore/shell/Controls/Dialogs)
<def:Placeholder name="Buttons"/>
In the xml for your custom application you add controls to this placeholder:
<control xmlns:def="Definition" xmlns="http://schemas.sitecore.net/Visual-Studio-Intellisense">
<MyCustomForm>
<FormDialog Icon="cool.png" Header="A really cool header" Text="Link or un-link items" OKButton="Close" CancelButton="false">
<CodeBeside Type="MyCustomCode.Dialogs.MyCustomForm, MyCustomCode"/>
<GridPanel Columns="2" CellPadding="4" Width="100%" Height="100%">
<!-- Panel code here -->
</GridPanel>
<Border def:placeholder="Buttons" runat="server" style="float:right;">
<Button Header="Link" runat="server" Type="button" Click="Link_Click" />
<Button Header="Unlink" runat="server" Type="button" Click="Unlink_Click" onclick="return confirm('Are you sure you want to unlink?');" />
</Border>
</FormDialog>
</MyCustomForm>
</control>
Note you want to pass in CancelButton="false" which hides the cancel button and set the OK button text to "Close". Handle your Link/Unlink button server actions in the code behind. I've styled the button group to float:right so they then site next to the Close button.

Related

hint in TextField doesn't display

I am working with Nativescript-Vue and have several text fields that I would like to put a little text in the background so the user knows what values (name, address, etc) should go in there. I don't have room for labels and I see that TextField has a hint...so my thinking is I should be able to use that? However, this doesn't render anything.
<StackLayout orientation="horizontal" width="*" class="box">
<TextField class="line-text" v-model="customer.firstName" hint="First Name" width="500px" marginBottom="2px" marginTop="2px"></TextField>
<TextField class="line-text" v-model="customer.lastName" hint="Last Name" width="500px" marginBottom="2px" marginTop="2px"></TextField>
</StackLayout>

(XAML UWP) Defining elements, including events for use across multiple pages (c++)

So I'm currently trying to centralize a few elements that I plan on using in several places in my App. For example I have a flyout that serves as a navigation menu in part of the app, but the problem I run into is that I can't set the "Click" event in the application resources where I define it in the App.xaml
<Application.Resources>
<Flyout x:Key="guided_tour_nav">
<StackPanel>
<Button x:Name="home" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Content="Return to Home" Click="home_button_Click"/>
<Button x:Name="water" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Content="The Water Enters"/>
<Button x:Name="eggs" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Content="Eggs Arrive"/>
<Button x:Name="pre_hatch" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Content="Pre-Hatching"/>
<Button x:Name="tanks" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Content="The Tanks"/>
<Button x:Name="life_support" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Content="Life Support"/>
<Button x:Name="waste" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Content="Filtering Waste"/>
<Button x:Name="release" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Content="The Release"/>
</StackPanel>
</Flyout>
</Application.Resources>
I use it in my mainpage.xaml, and a few other pages
<Button Flyout="{StaticResource guided_tour_nav}" Content="Jump to Section"/>
I'm currently getting the error
WMC1005 Events cannot be set in the Application class XAML file
I would like to be able to define the whole element, click events and all, to be referenced wherever I need it without having to redefine the click events for each page. I imagine it must be possible somehow, but I'm completely new to the UWP platform.
When you create a Flyout as a resource in Application.Resources, you cannot use it with events, unfortunately.
There are however two alternative solutions.
Custom User Control
You can wrap the Flyout into a custom XAML user control and then easily reuse anywhere you want.
Right-click your UWP project in Solution Explorer and select Add - New item.... In the dialog select the XAML section and there find User Control option. Select the desired name (for example GuidedTourNav) and click Add.
This creates three files - GuidedTourNavFlyout.xaml, GuidedTourNavFlyout.xaml.h and GuidedTourNavFlyout.xaml.cpp. The default type of custom XAML controls is UserControl. You need to change this. Open the GuidedTourNavFlyout.xaml file and change the root element from UserControl to Flyout:
<Flyout
x:Class="xxxxxx"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="xxxxxxx"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
</Flyout>
Finally, replace the Grid inside the GuidedTourNavFlyout.xaml code with your flyout contents and create the desired event handler in the code-behind as usual.
Now you can use your custom flyout anywhere. First add a XML namespace declaration to the root element of your page. Replace MyApp.CustomControls with the namespace where your custom control lies.
xmlns:controls="using:MyApp.CustomControls"
And now you can use your flyout anywhere you want using complex property:
<Button Content="Hello">
<Button.Flyout>
<controls:GuidedTourNavFlyout />
</Button.Flyout>
</Button>
Using Resource Dictionary with code-behind
Alternative solution would be to create a Resource Dictionary with code-behind as described here. However this approach seems a bit less clean and I cannot confirm it works in C++.

Ember's input helper need double click to edit in ie11

<div draggable="true">
{{input value="default value" }}
</div>
In ember.js, as above code, when the div element has an attribute 'draggable="true"', on the webpage, the input area must need a double-click to edit in ie-11, but in chrome or firefox, it just need a click event to edit. Has anyone resolved this issue?
seems to be a bug
[IE 11] Input field of type text does not respond to mouse clicks when ancestor node has draggable=true
bad workaround:
<div style="background-color:lightgray" id="dragE" draggable="true">
<input id="inputE" type="text" />
</div>
click on the lightgray background
now the input field support single click
$('#dragE').focus(); <br>
$('#inputE').focus();<br>
was my solution
unfotunately reproducing with pluncer & co. did not work.
Or...set attribute draggable to "false", when the page goes to a production environment.
This worked for us.

How to add and save entry in dropdown listbox using coldfusion

Id like to make a drop down list box where in at the end of the list, an option "Enter New housing", that if selected there will be a message box then it will automatically saves on the database and refreshes the object.
Im a beginner and this is what ive started:
<cfquery name="housingsel" datasource=" " dbtype=" ">
select rtrim(housing_name) as housing, housingid as housingid from housing order by housing
</cfquery>
<!---<cfquery name="housingins" datasource=" " dbtype=" ">
insert into housing (housingid,housing_name) values (1,'Tierra Pura Housing')
</cfquery>--->
<body>
<div class="container">
<div class="content">
<h1>Housing</h1>
<table width="300" bgcolor="#FFFFFF" cellpadding="2" cellspacing="0" border="0">
<cfform action="de_housing.cfm" method="POST">
<tr><td height="20" class="lbl" align="right">Housing</td><td>
<select name="housingcat">
<CFOUTPUT QUERY="housingsel">
<OPTION VALUE="#housingid#">#housing#</OPTION>
</CFOUTPUT>
<option value="new">Enter New Housing</option>
</select>
</td></tr>
<tr><td height="20" class="lbl"></td><td align="left">
</td></tr>
</cfform>
</table>
Please help!
Thanks!
First off, avoid cfform at all costs. It will not help you. See https://github.com/cfjedimaster/ColdFusion-UI-the-Right-Way for reasons why and examples of how to do stuff the right way.
That being said, what you want to do isn't difficult. Let's break it down.
> "Id like to make a drop down list box where in at the end of the list, an option "Enter New housing", that if selected "
Using jQuery, you would add a change handler to your dropdown. In that change handler, you can get the selected index of the drop down. If that index is equal to the length of the options, then the user has picked the last one.
> "there will be a message box"
You have a few choices here. One simple, but not pretty way, is to use the built in confirm option. It has a simple modal box API that the user can type in. There are pretty options, like jQuery UI dialogs, but the confirm option is super simple. I'd recommend starting there.
> "automatically saves on the database"
So, you will know when a user enters a value into the confirm. Take that and use jQuery to do an XHR (Ajax) hit to your code. You will need to write CF code to respond to this request and insert it into the db. Not too difficult and it has been shown many places elsewhere. I'd also add logic to check for dupes.
> "refreshes the object"
When you do a XHR in jQuery, you know when the server is done doing crap, so in the response handler, you can add a new option to the drop down. This too has been done many times before, just Google for adding an option to a drop down. (You will probably end up back here.)

how to add addtional buttons by using sitecore webform for marketer

When i create a new form in sitecore by using the sitecore webform for marketer module.the form already have a default submit button , but i want to add another button like clear form function.
How could i add a new button in the form design backend?
Thanks.
I don't believe there's a built-in way to add a clear button, but you should refer to the WFFM User Guide (PDF link) on the SDN on how to use the Form Builder GUI to add fields and buttons/actions.
There's not a built-in way to add a clear button,but you may customize via jquery:
1.add a sublayout(ascx) page ,then do following
<div class="myDiv sub">
<sc:Placeholder ID="phForm" runat="server" Key="Form" />
<asp:HiddenField runat="server" ID="hfCancelButtonText" ClientIDMode="Static" />
<div class="clear"></div>
</div>
Then do following in jquery
//adding reset-button in web-forms
if ($('.scfForm .scfSubmitButtonBorder').length > 0) {
$('.myDiv .scfForm .scfSubmitButtonBorder').prepend('<input type="Reset" class="reset-button" />');
}
//adding reset-button text in My-Account web-form
var $hfCancelButtonText = $('.myDiv').find('#hfCancelButtonText').val();
$('.my-account-detail').find('.reset-button').val($hfCancelButtonText);