<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Webmuch</title>
	<atom:link href="http://webmuch.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://webmuch.com/</link>
	<description>Web Development Company</description>
	<lastBuildDate>Sat, 14 Mar 2015 07:59:29 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://webmuch.com/wp-content/uploads/2018/05/cropped-favicon-32x32.png</url>
	<title>Webmuch</title>
	<link>https://webmuch.com/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How To Create A Swing Application Using NetBeans Swing Builder</title>
		<link>https://webmuch.com/how-to-create-a-swing-application-using-netbeans-swing-builder/</link>
					<comments>https://webmuch.com/how-to-create-a-swing-application-using-netbeans-swing-builder/#respond</comments>
		
		<dc:creator><![CDATA[Jojo]]></dc:creator>
		<pubDate>Tue, 10 Mar 2015 05:48:36 +0000</pubDate>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[GUI builder]]></category>
		<category><![CDATA[Java Netbeans]]></category>
		<category><![CDATA[netbeans]]></category>
		<category><![CDATA[netbeans swing builder]]></category>
		<category><![CDATA[swing application]]></category>
		<category><![CDATA[swing UI]]></category>
		<guid isPermaLink="false">http://webmuch.com/?p=15509</guid>

					<description><![CDATA[<p>&#160; This article explains the few basic steps to create a String program on Java NetBean and showing a background image in the frame. There are two approaches to generate this feature, one is by heavy coding, second is to simply use drag and drop actions from the Jpanel of the Jframe windows. &#160; &#160; &#160;         ... </p>
<div><a href="https://webmuch.com/how-to-create-a-swing-application-using-netbeans-swing-builder/" class="more-link">Read More</a></div>
<p>The post <a href="https://webmuch.com/how-to-create-a-swing-application-using-netbeans-swing-builder/">How To Create A Swing Application Using NetBeans Swing Builder</a> appeared first on <a href="https://webmuch.com">Webmuch</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>&nbsp;</p>
<p>This article explains the few basic steps to create a String program on <strong>Java NetBean</strong> and showing a background image in the frame. There are two approaches to generate this feature, one is by heavy coding, second is to simply use drag and drop actions from the <strong>Jpanel</strong> of the <strong>Jframe windows.</strong></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><span style="font-size: medium;">                           <strong>Steps to create a new Program Swing Application Project:</strong></span></p>
<ol>
<li>Choose a File as  &#8216;New Project&#8217;. This can be done alternately by clicking the New Project icon in the<strong> IDE</strong> toolbar.</li>
<li>Select the <strong>Java node</strong> in the <strong>Categories pane</strong>, and in the <strong>Projects pane</strong> choose <strong>Java application</strong>.(Click Next)</li>
<li>Enter <strong>Project Name </strong>as <strong>ProgramSwing</strong> and Specify the project location.</li>
<li>Leave the check box for <strong>Use Dedicated Folder</strong> unchecked, for Storing Libraries.</li>
<li>Make sure that the check box for set as <strong>Main Project</strong> is checked and clear the <strong>Create Main Class field.</strong></li>
<li>Click Finish.</li>
</ol>
<p style="text-align: left;"><span style="font-size: medium;">    The IDE Swing Application creates the ProgramSwing folder in the designated location in your system. This folder contains all of the project&#8217;s associated files, including scripts, folders for storing source and tests as well as folders for project-specific metadata. To view the project structure, use the IDE&#8217;s File window.</span></p>
<p>&nbsp;</p>
<p><a href="http://webmuch.com/how-to-create-a-swing-application-using-netbeans-swing-builder/1-8/" rel="attachment wp-att-15671"><img fetchpriority="high" decoding="async" class="aligncenter wp-image-15671" src="http://webmuch.com/wp-content/uploads/2015/02/1-e1423226125593.png" alt="1" width="800" height="450" /></a></p>
<h3></h3>
<h3>Creating a Jframe Container</h3>
<p style="padding-left: 90px; text-align: left;"><span style="font-size: medium;">After creating the new application, you may have noticed that the source packages folder in the projects window contains an empty <strong>&lt;ProgramSwing Package&gt;</strong> node. To proceed with build our interface, we need to create a <strong>java container</strong> in which we will place the other required <strong>GUI</strong> components. In this step, we create a container using the <strong>Jframe</strong> component and place the container in a new package.</span></p>
<p style="padding-left: 90px; text-align: left;"><span style="font-size: medium;">The IDE Swing Application creates the <strong>ProgramSwingUI</strong> form and also creates the <strong>ProgramSwing class</strong> with in the <strong>ProgramSwingUI.java application</strong> and opens the <strong>ProgramSwingUI</strong> form in the <strong>GUI Builder.</strong></span></p>
<p>&nbsp;</p>
<p><strong>                          The following shows how the Default package is replaced by my.ProgramSwing package:</strong></p>
<ol>
<li>In the project window, right-click on the ProgramSwing node and choose <strong>New&gt;JFrame Form</strong>. Alternately, you will find a <strong>Jframe</strong> form by choosing <strong>New&gt;JFrame Form</strong>.</li>
<li>Enter <strong>ProgramSwingUI</strong> as the Class Name.</li>
<li>Enter <strong>my.ProgramSwing</strong> as the package.</li>
<li>Click Finish.</li>
</ol>
<p><img decoding="async" class="aligncenter wp-image-15684" src="http://webmuch.com/wp-content/uploads/2015/02/2.png" alt="2" width="800" height="450" srcset="https://webmuch.com/wp-content/uploads/2015/02/2.png 1366w, https://webmuch.com/wp-content/uploads/2015/02/2-100x56.png 100w, https://webmuch.com/wp-content/uploads/2015/02/2-979x550.png 979w, https://webmuch.com/wp-content/uploads/2015/02/2-1350x759.png 1350w" sizes="(max-width: 800px) 100vw, 800px" /></p>
<h3 style="padding-left: 60px;"></h3>
<h3 style="padding-left: 60px;">How to Add the BackGround Images for Jframe</h3>
<p style="text-align: left; padding-left: 90px;"><span style="font-size: medium;">Adding the Background image is just the matter of few drags and drops. Open the Jframe windows, drag the Panel from the Palette which is located in the upper right corner to the Design area.</span></p>
<p>&nbsp;</p>
<p><img decoding="async" class="aligncenter wp-image-15685" src="http://webmuch.com/wp-content/uploads/2015/02/3.png" alt="3" width="800" height="450" srcset="https://webmuch.com/wp-content/uploads/2015/02/3.png 1366w, https://webmuch.com/wp-content/uploads/2015/02/3-100x56.png 100w, https://webmuch.com/wp-content/uploads/2015/02/3-979x550.png 979w, https://webmuch.com/wp-content/uploads/2015/02/3-1350x759.png 1350w" sizes="(max-width: 800px) 100vw, 800px" /></p>
<p>&nbsp;</p>
<ol>
<li><span style="font-size: medium;"><b>Add a Jlabel</b></span></li>
</ol>
<p style="padding-left: 60px;"><span style="font-size: medium;">Drag a <strong>Jlabel</strong> into the Design Area. Place it on the left of the <strong>JtextField</strong>, again look for <strong>visual cues</strong> that suggest an appropriate amount of spacing. Make sure that text base for this component is aligned with that of the JtextField. Go to the <strong>Jlable</strong> Properties, click the font option than select as Font Design, font size, bold as per your choice. Set the height and width, go to text option and write the name &#8216;Subscribe Us&#8217; and select foreground color.</span></p>
<p>&nbsp;</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-15686" src="http://webmuch.com/wp-content/uploads/2015/02/4.png" alt="4" width="800" height="450" srcset="https://webmuch.com/wp-content/uploads/2015/02/4.png 1366w, https://webmuch.com/wp-content/uploads/2015/02/4-100x56.png 100w, https://webmuch.com/wp-content/uploads/2015/02/4-979x550.png 979w, https://webmuch.com/wp-content/uploads/2015/02/4-1350x759.png 1350w" sizes="auto, (max-width: 800px) 100vw, 800px" /></p>
<p>&nbsp;</p>
<ol start="2">
<li><span style="font-size: medium;"><b>Add a JtextField</b></span></li>
</ol>
<p style="padding-left: 60px;"><span style="font-size: medium;">Now, Drag a <strong>JtextField</strong> from the Palette to the upper right corner of the Design Area. As you approach the upper right corner, the GUI builder provides visual cues (dashed lines) that suggest the appropriate spacing. Using these cues as a guide, drop a <strong>JtextField</strong> into the upper Right hand corner. Go to the JtextField Properties click the font option than select FontDesign, fontsize, Bold as per your choice. Set the height and width.</span></p>
<p>&nbsp;</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-15687" src="http://webmuch.com/wp-content/uploads/2015/02/5.png" alt="5" width="800" height="450" srcset="https://webmuch.com/wp-content/uploads/2015/02/5.png 1366w, https://webmuch.com/wp-content/uploads/2015/02/5-100x56.png 100w, https://webmuch.com/wp-content/uploads/2015/02/5-979x550.png 979w, https://webmuch.com/wp-content/uploads/2015/02/5-1350x759.png 1350w" sizes="auto, (max-width: 800px) 100vw, 800px" /></p>
<p>&nbsp;</p>
<ol start="3">
<li><span style="font-size: medium;"><b>Add a Jbutton<b></b></b></span></li>
</ol>
<p style="padding-left: 60px;"><span style="font-size: medium;">Next, drag a <strong>Jbutton</strong> form the Palette and drop it in to the left side and underneath the <strong>JtextField. </strong>Go to the <strong>Jbutton</strong> properties select the button images, Button size, Height, Width.</span></p>
<p>&nbsp;</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-15688" src="http://webmuch.com/wp-content/uploads/2015/02/6.png" alt="6" width="800" height="450" srcset="https://webmuch.com/wp-content/uploads/2015/02/6.png 1366w, https://webmuch.com/wp-content/uploads/2015/02/6-100x56.png 100w, https://webmuch.com/wp-content/uploads/2015/02/6-979x550.png 979w, https://webmuch.com/wp-content/uploads/2015/02/6-1350x759.png 1350w" sizes="auto, (max-width: 800px) 100vw, 800px" /></p>
<p>&nbsp;</p>
<ol start="4">
<li><span style="font-size: medium;"><b>Add an another Jlable</b></span></li>
</ol>
<p style="padding-left: 60px;">And last, drag a <strong>Jlabel</strong> into the Design Area. Place it to the top of the <strong>Jpanel Field</strong>, again looking for visual cues that suggest an appropriate amount of spacing. Make sure that text base for this component is aligned with that of the <strong>Jform</strong>. Go to the <strong>Navigator window</strong> and drag the all three fields. <strong>Jlable, Jtextfield, Jbutton</strong> above the last<strong> Jlable3[Jlable]</strong>.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-15689" src="http://webmuch.com/wp-content/uploads/2015/02/7.png" alt="7" width="800" height="450" srcset="https://webmuch.com/wp-content/uploads/2015/02/7.png 1366w, https://webmuch.com/wp-content/uploads/2015/02/7-100x56.png 100w, https://webmuch.com/wp-content/uploads/2015/02/7-979x550.png 979w, https://webmuch.com/wp-content/uploads/2015/02/7-1350x759.png 1350w" sizes="auto, (max-width: 800px) 100vw, 800px" /></p>
<p>&nbsp;</p>
<p style="padding-left: 60px;"><span style="font-size: medium;">Go to the <strong>Jlable</strong> Properties and select the <strong>Icon</strong> option, open the <strong>Jlable-icon</strong> window select the External image radio button and then choose the image in <strong>ProgramSwing/Src/programSwing</strong> and select images.</span></p>
<p style="padding-left: 60px;">Click OK, and Finish up.</p>
<p style="padding-left: 60px;">
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-15690" src="http://webmuch.com/wp-content/uploads/2015/02/8.png" alt="8" width="800" height="450" srcset="https://webmuch.com/wp-content/uploads/2015/02/8.png 1366w, https://webmuch.com/wp-content/uploads/2015/02/8-100x56.png 100w, https://webmuch.com/wp-content/uploads/2015/02/8-979x550.png 979w, https://webmuch.com/wp-content/uploads/2015/02/8-1350x759.png 1350w" sizes="auto, (max-width: 800px) 100vw, 800px" /></p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-15691" src="http://webmuch.com/wp-content/uploads/2015/02/9.png" alt="9" width="800" height="421" srcset="https://webmuch.com/wp-content/uploads/2015/02/9.png 452w, https://webmuch.com/wp-content/uploads/2015/02/9-100x53.png 100w" sizes="auto, (max-width: 800px) 100vw, 800px" /></p>
<p>&nbsp;</p>
<p style="padding-left: 60px;"><span style="text-decoration: underline;"><b>Image.java source code</b></span></p>
<p style="padding-left: 60px;">To view the code for creating Swing Application, which is generated automatically, click on the <strong>source</strong> option.</p>
<pre class="lang:default decode:true">package programswing;

public class Image extends javax.swing.JFrame
{

/**
* Creates new form Image
*/

	public Image()
	{

		initComponents();

	}

/*** This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor
*/

	@SuppressWarnings("unchecked")

// &lt;editor-fold defaultstate="collapsed" desc="Generated Code"&gt;

	private void initComponents()
	{

		jPanel1 = new javax.swing.JPanel();
		jLabel3 = new javax.swing.JLabel();
		jTextField1 = new javax.swing.JTextField();
		jButton1 = new javax.swing.JButton();
		jLabel1 = new javax.swing.JLabel();

		setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
		setMaximumSize(new java.awt.Dimension(600, 600));
		jPanel1.setBackground(new java.awt.Color(205, 219, 232));
		jPanel1.setMinimumSize(new java.awt.Dimension(280, 280));
		jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
		jLabel3.setFont(new java.awt.Font("Lucida Sans", 0, 24)); // NOI18N
		jLabel3.setForeground(java.awt.Color.white);
		jLabel3.setText("SUBSCRIBE US");
		jLabel3.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
		jPanel1.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 90, 180, 28));
		jPanel1.add(jTextField1, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 130, 200, 40));
		jButton1.setFont(new java.awt.Font("Ubuntu", 1, 14)); // NOI18N
		jButton1.setForeground(new java.awt.Color(59, 4, 4));
		jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/programswing/buttonimg.png"))); // NOI18N
		jButton1.setMaximumSize(new java.awt.Dimension(64, 64));
		jButton1.setMinimumSize(new java.awt.Dimension(32, 32));
		jButton1.addActionListener(new java.awt.event.ActionListener()
		{
			public void actionPerformed(java.awt.event.ActionEvent evt) 
			{
				jButton1ActionPerformed(evt);
			}
		});

		jPanel1.add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 20, 50, 50));
		jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/programswing/1606264.jpg"))); // NOI18N
		jPanel1.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(-10, -10, 330, 260));
		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(
			layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
			.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
		);

		layout.setVerticalGroup(
			layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
			.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
		);

		pack();
	}
	// &lt;/editor-fold&gt;

	private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
	}

	/**
	* @param args the command line arguments
	*/

	public static void main(String args[])
	{
		/* Set the Nimbus look and feel 
		*/

		//&lt;editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "&gt;

		/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
		* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
		*/

		try{

			for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
				if ("Nimbus".equals(info.getName())) {
					javax.swing.UIManager.setLookAndFeel(info.getClassName());
					break;
				}
			}
		} 
		catch (ClassNotFoundException ex) {
			java.util.logging.Logger.getLogger(Image.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
		} 
		catch (InstantiationException ex) {
			java.util.logging.Logger.getLogger(Image.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
		}
	 	catch (IllegalAccessException ex) {
			java.util.logging.Logger.getLogger(Image.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
		} 
		catch (javax.swing.UnsupportedLookAndFeelException ex) {
			java.util.logging.Logger.getLogger(Image.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
		}

		//&lt;/editor-fold&gt;
		/* Create and display the form 
		*/

		java.awt.EventQueue.invokeLater(new Runnable() {
			public void run() {
				new Image().setVisible(true);
			}
		});
	}

	// Variables declaration - do not modify

	private javax.swing.JButton jButton1;
	private javax.swing.JLabel jLabel1;
	private javax.swing.JLabel jLabel3;
	private javax.swing.JPanel jPanel1;
	private javax.swing.JTextField jTextField1;

	// End of variables declaration
}</pre>
<p>&nbsp;</p>
<p style="padding-left: 60px;">Show the output box message:BUILD SUCCESSFUL(total time: 0 seconds)</p>
<p style="padding-left: 60px;">Press Shift+F6 to run the programSwing.java</p>
<p>&nbsp;</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-15692" src="http://webmuch.com/wp-content/uploads/2015/02/10.png" alt="10" width="800" height="450" srcset="https://webmuch.com/wp-content/uploads/2015/02/10.png 1366w, https://webmuch.com/wp-content/uploads/2015/02/10-100x56.png 100w, https://webmuch.com/wp-content/uploads/2015/02/10-979x550.png 979w, https://webmuch.com/wp-content/uploads/2015/02/10-1350x759.png 1350w" sizes="auto, (max-width: 800px) 100vw, 800px" /></p>
<p style="padding-left: 60px;">Do subscribe to our newsletter if you think this tutorial was worth your time. Please share, and happy reading.</p>
<p style="padding-left: 60px;">Cheers!</p>
<p>&nbsp;</p>
<h3 style="text-align: center;">FOR MORE AWESOME TUTORIALS:</h3>
<div  class="x-column x-sm x-1-2" style="" >
<h4 style="text-align: center;"><a href="http://webmuch.com/how-to-customize-a-file-upload-button-using-css3-html5-and-javascript/">How To Customize A File Upload Button Using CSS3, HTML5 and Javascript</a></h4>
<p style="text-align: center;"><a href="http://webmuch.com/how-to-customize-a-file-upload-button-using-css3-html5-and-javascript/"><img loading="lazy" decoding="async" class=" wp-image-15838 alignnone" src="http://webmuch.com/wp-content/uploads/2015/03/customized-file-upload-1.jpg" alt="customized-file-upload (1)" width="348" height="224" srcset="https://webmuch.com/wp-content/uploads/2015/03/customized-file-upload-1.jpg 846w, https://webmuch.com/wp-content/uploads/2015/03/customized-file-upload-1-100x64.jpg 100w" sizes="auto, (max-width: 348px) 100vw, 348px" /></a></p>
</div>
<div  class="x-column x-sm x-1-2 last" style="" >
<h4 style="text-align: center;"><a href="http://webmuch.com/how-to-insert-symfony2-captcha-to-login-page-in-fosuserbundle/"> How To Insert Symfony2 Captcha To Login Page In FOSUserBundle</a></h4>
<p style="text-align: center;"><a href="http://webmuch.com/how-to-insert-symfony2-captcha-to-login-page-in-fosuserbundle/"><img loading="lazy" decoding="async" class="alignnone wp-image-15782" src="http://webmuch.com/wp-content/uploads/2015/02/captcha-design.png" alt="captcha design" width="358" height="216" srcset="https://webmuch.com/wp-content/uploads/2015/02/captcha-design.png 932w, https://webmuch.com/wp-content/uploads/2015/02/captcha-design-100x60.png 100w" sizes="auto, (max-width: 358px) 100vw, 358px" /></a></p>
</div>
<div  class="x-column x-sm x-1-2" style="" >
<h4 style="text-align: center;"><a href="http://webmuch.com/upgrade-bootstrap-2-twitter-bootstrap3-build/"> How To Upgrade Bootstrap 2 To Twitter Bootstrap 3 Build</a></h4>
<p style="text-align: center;"><a href="http://webmuch.com/upgrade-bootstrap-2-twitter-bootstrap3-build/"><img loading="lazy" decoding="async" class="alignnone wp-image-15775" src="http://webmuch.com/wp-content/uploads/2015/02/bootstrap2-Vs-3-Img.png" alt="bootstrap2 Vs 3 Img" width="339" height="290" srcset="https://webmuch.com/wp-content/uploads/2015/02/bootstrap2-Vs-3-Img.png 986w, https://webmuch.com/wp-content/uploads/2015/02/bootstrap2-Vs-3-Img-100x86.png 100w, https://webmuch.com/wp-content/uploads/2015/02/bootstrap2-Vs-3-Img-979x841.png 979w" sizes="auto, (max-width: 339px) 100vw, 339px" /></a></p>
</div>
<div  class="x-column x-sm x-1-2 last" style="" >
<h4 style="text-align: center;"><a href="http://webmuch.com/embed-eav-model-symfony2-collection-form/">How To Embed EAV Model In Symfony2 Collection Form</a></h4>
<p style="text-align: center;"><a href="http://webmuch.com/embed-eav-model-symfony2-collection-form/"><img loading="lazy" decoding="async" class="alignnone wp-image-15725" src="http://webmuch.com/wp-content/uploads/2015/02/newfeatimagecollection.png" alt="newfeatimagecollection" width="346" height="216" srcset="https://webmuch.com/wp-content/uploads/2015/02/newfeatimagecollection.png 800w, https://webmuch.com/wp-content/uploads/2015/02/newfeatimagecollection-100x63.png 100w" sizes="auto, (max-width: 346px) 100vw, 346px" /></a></p>
</div><span id="more-15509"></span></p>
<p>The post <a href="https://webmuch.com/how-to-create-a-swing-application-using-netbeans-swing-builder/">How To Create A Swing Application Using NetBeans Swing Builder</a> appeared first on <a href="https://webmuch.com">Webmuch</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://webmuch.com/how-to-create-a-swing-application-using-netbeans-swing-builder/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How To Customize A File Upload Button Using CSS3, HTML5 and Javascript</title>
		<link>https://webmuch.com/how-to-customize-a-file-upload-button-using-css3-html5-and-javascript/</link>
					<comments>https://webmuch.com/how-to-customize-a-file-upload-button-using-css3-html5-and-javascript/#respond</comments>
		
		<dc:creator><![CDATA[Jojo]]></dc:creator>
		<pubDate>Tue, 03 Mar 2015 08:49:45 +0000</pubDate>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Tutorial]]></category>
		<guid isPermaLink="false">http://webmuch.com/?p=15799</guid>

					<description><![CDATA[<p>Today we are customizing a file upload button using CSS3, HTML5 and Javascript . If you have ever tried this earlier then you would know customizing a  file upload button is very difficult. Now, I am going to try and explain the process to you in a simpler way. So, take a look at how we customize a file upload button. Here, ... </p>
<div><a href="https://webmuch.com/how-to-customize-a-file-upload-button-using-css3-html5-and-javascript/" class="more-link">Read More</a></div>
<p>The post <a href="https://webmuch.com/how-to-customize-a-file-upload-button-using-css3-html5-and-javascript/">How To Customize A File Upload Button Using CSS3, HTML5 and Javascript</a> appeared first on <a href="https://webmuch.com">Webmuch</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Today we are customizing a file upload button using CSS3, HTML5 and Javascript . If you have ever tried this earlier then you would know customizing a  file upload button is very difficult. Now, I am going to try and explain the process to you in a simpler way.</p>
<p> <strong>So, take a look at how we customize a file upload button.</strong><br />
Here, we are creating a new file upload button on image icon which behaves consistently in pure &#8220;css cross browser&#8221;.<br />
 &nbsp;<br />
<strong> And here we begin with:</strong></p>
<p><b><strong>Step 1: index.html</strong></b></p>
<p>The only HTML5 feature is the “multiple” attribute which allows the user to select any number of files.</p>
<p><img loading="lazy" decoding="async" class="aligncenter  wp-image-15837" src="http://webmuch.com/wp-content/uploads/2015/03/HTML5_logo_and_wordmark.svg_.png" alt="HTML5_logo_and_wordmark.svg" width="191" height="191" srcset="https://webmuch.com/wp-content/uploads/2015/03/HTML5_logo_and_wordmark.svg_.png 2000w, https://webmuch.com/wp-content/uploads/2015/03/HTML5_logo_and_wordmark.svg_-100x100.png 100w, https://webmuch.com/wp-content/uploads/2015/03/HTML5_logo_and_wordmark.svg_-979x979.png 979w, https://webmuch.com/wp-content/uploads/2015/03/HTML5_logo_and_wordmark.svg_-1350x1350.png 1350w" sizes="auto, (max-width: 191px) 100vw, 191px" /><br />
The HTML markup is pretty simple, we just want to create a button which can be placed anywhere in the form:</p>
<pre class="lang:default decode:true">&lt;div class="fileUpload"&gt;
&lt;span class="custom-span"&gt;+&lt;/span&gt;
&lt;p class="custom-para"&gt;Add Images&lt;/p&gt;
&lt;input id="uploadBtn" type="file" class="upload" /&gt;
&lt;/div&gt;
&lt;input id="uploadFile" placeholder="0 files selected" disabled="disabled" /&gt;</pre>
<p><span style="line-height: 1.5;">In the code above, at first we make two input tags with id. One of them will be &#8220;uploadBtn&#8221; which is used to upload the file, and other will be &#8220;uploadFile&#8221; which is actually used to display the name of the image being uploaded.</span></p>
<p><b>Step 2: <strong>CSS included</strong></b></p>
<p>While we are in the CSS, let&#8217;s just style our custom file upload button:</p>
<pre class="lang:default decode:true">.fileUpload {
	position: relative;
	overflow: hidden;
	margin: 10px;
	background-color: #BDBDBD;
	height: 200px;
	width: 200px;
	text-align: center;
}
.fileUpload input.upload {
	position: absolute;
	top: 0;
	right: 0;
	margin: 0;
	padding: 0;
	font-size: 20px;
	cursor: pointer;
	opacity: 0;
	filter: alpha(opacity=0);
	height: 100%;
	text-align: center;
}
.custom-span{ font-family: Arial; font-weight: bold;font-size: 100px; color: #FE57A1}
#uploadFile{border: none;margin-left: 10px; width: 200px;}
.custom-para{font-family: arial;font-weight: bold;font-size: 24px; color:#585858;}</pre>
<p><img loading="lazy" decoding="async" class="aligncenter  wp-image-15834" src="http://webmuch.com/wp-content/uploads/2015/03/Myd94.jpg" alt="Myd94" width="325" height="285" srcset="https://webmuch.com/wp-content/uploads/2015/03/Myd94.jpg 342w, https://webmuch.com/wp-content/uploads/2015/03/Myd94-100x88.jpg 100w" sizes="auto, (max-width: 325px) 100vw, 325px" /></p>
<p>Now, you can use any type of a styling without worrying how to change default styles. In the CSS part, we need to define the dimensions-width and height-of the button as well as background and style the button text. In the above code, we have to used a class named &#8220;fileUpload&#8221; which actually sets the position of the &#8220;div&#8221; to &#8220;relative&#8221; (means it&#8217;ll work within the entire div section and not at the position where the file upload tag is used ). So, use this one to build your custom file upload button.</p>
<p><strong> Step 3: Javascript</strong></p>
<pre class="lang:default decode:true">&lt;script type="text/javascript"&gt;
document.getElementById("uploadBtn").onchange = function () {
document.getElementById("uploadFile").value = this.value;
};
&lt;/script&gt;</pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-15836" src="http://webmuch.com/wp-content/uploads/2015/03/customize-upload-button1.png" alt="customize upload button" width="588" height="280" srcset="https://webmuch.com/wp-content/uploads/2015/03/customize-upload-button1.png 588w, https://webmuch.com/wp-content/uploads/2015/03/customize-upload-button1-100x48.png 100w" sizes="auto, (max-width: 588px) 100vw, 588px" /></p>
<p>Using this script, we display the name of the images being uploaded by user in the textbox. Make sure you add the appropriate javascript in with the button to make it call the function.</p>
<p>For any doubts and queries, feel free to leave comments below. Remember to subscribe to our newsletter. Do share the tutorial if you think it’s worth it.</p>
<p>Happy Reading!</p>
<h3 style="text-align: center;">FOR MORE AWESOME TUTORIALS:</h3>
<div  class="x-column x-sm x-1-2" style="" >
<h4 style="text-align: center;"><a href="http://webmuch.com/how-to-insert-symfony2-captcha-to-login-page-in-fosuserbundle/"> How To Insert Symfony2 Captcha To Login Page In FOSUserBundle</a></h4>
<p style="text-align: center;"><a href="http://webmuch.com/how-to-insert-symfony2-captcha-to-login-page-in-fosuserbundle/"><img loading="lazy" decoding="async" class="  wp-image-15782 alignnone" src="http://webmuch.com/wp-content/uploads/2015/02/captcha-design.png" alt="captcha design" width="314" height="189" srcset="https://webmuch.com/wp-content/uploads/2015/02/captcha-design.png 932w, https://webmuch.com/wp-content/uploads/2015/02/captcha-design-100x60.png 100w" sizes="auto, (max-width: 314px) 100vw, 314px" /></a></p>
</div>
<div  class="x-column x-sm x-1-2 last" style="" >
<h4 style="text-align: center;"><a href="http://webmuch.com/upgrade-bootstrap-2-twitter-bootstrap3-build/"> How To Upgrade Bootstrap 2 To Twitter Bootstrap 3 Build</a></h4>
<p style="text-align: center;"><a href="http://webmuch.com/upgrade-bootstrap-2-twitter-bootstrap3-build/"><img loading="lazy" decoding="async" class="  wp-image-15775 alignnone" src="http://webmuch.com/wp-content/uploads/2015/02/bootstrap2-Vs-3-Img.png" alt="bootstrap2 Vs 3 Img" width="283" height="243" srcset="https://webmuch.com/wp-content/uploads/2015/02/bootstrap2-Vs-3-Img.png 986w, https://webmuch.com/wp-content/uploads/2015/02/bootstrap2-Vs-3-Img-100x86.png 100w, https://webmuch.com/wp-content/uploads/2015/02/bootstrap2-Vs-3-Img-979x841.png 979w" sizes="auto, (max-width: 283px) 100vw, 283px" /></a></p>
</div>
<div  class="x-column x-sm x-1-2" style="" >
<h4 style="text-align: center;"><a href="http://webmuch.com/embed-eav-model-symfony2-collection-form/">How To Embed EAV Model In Symfony2 Collection Form</a></h4>
<p style="text-align: center;"><a href="http://webmuch.com/embed-eav-model-symfony2-collection-form/"><img loading="lazy" decoding="async" class="  wp-image-15725 alignnone" src="http://webmuch.com/wp-content/uploads/2015/02/newfeatimagecollection.png" alt="newfeatimagecollection" width="319" height="200" srcset="https://webmuch.com/wp-content/uploads/2015/02/newfeatimagecollection.png 800w, https://webmuch.com/wp-content/uploads/2015/02/newfeatimagecollection-100x63.png 100w" sizes="auto, (max-width: 319px) 100vw, 319px" /></a></p>
</div>
<div  class="x-column x-sm x-1-2 last" style="" >
<h4 style="text-align: center;"><a href="http://webmuch.com/override-fosuserbundle/"> How To Override FOSUserBundle</a></h4>
<p style="text-align: center;"><a href="http://webmuch.com/override-fosuserbundle/"><img loading="lazy" decoding="async" class="  wp-image-15674 alignnone" src="http://webmuch.com/wp-content/uploads/2015/02/symfonyplusfos.png" alt="symfonyplusfos" width="313" height="235" srcset="https://webmuch.com/wp-content/uploads/2015/02/symfonyplusfos.png 638w, https://webmuch.com/wp-content/uploads/2015/02/symfonyplusfos-100x75.png 100w" sizes="auto, (max-width: 313px) 100vw, 313px" /></a></p>
</div>
<p>The post <a href="https://webmuch.com/how-to-customize-a-file-upload-button-using-css3-html5-and-javascript/">How To Customize A File Upload Button Using CSS3, HTML5 and Javascript</a> appeared first on <a href="https://webmuch.com">Webmuch</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://webmuch.com/how-to-customize-a-file-upload-button-using-css3-html5-and-javascript/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How To Insert Symfony2 Captcha To Login Page In FOSUserBundle</title>
		<link>https://webmuch.com/how-to-insert-symfony2-captcha-to-login-page-in-fosuserbundle/</link>
					<comments>https://webmuch.com/how-to-insert-symfony2-captcha-to-login-page-in-fosuserbundle/#respond</comments>
		
		<dc:creator><![CDATA[Jojo]]></dc:creator>
		<pubDate>Tue, 24 Feb 2015 08:57:03 +0000</pubDate>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[foscaptcha]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Captcha]]></category>
		<category><![CDATA[captcha builder]]></category>
		<category><![CDATA[captcha login]]></category>
		<category><![CDATA[FOS Bundle]]></category>
		<category><![CDATA[fosuserbundle]]></category>
		<category><![CDATA[Symfony2]]></category>
		<guid isPermaLink="false">http://webmuch.com/?p=15397</guid>

					<description><![CDATA[<p>Ever wonder why computers sometimes ask you to prove you’re human? When a user tries to login to a website and fails twice, the computer asks the user to enter some code which is readable by human only in the third attempt, this is done to check whether the user is a machine or a human. Since hacking has touched another level, captcha is used to check whether the system is being accessed ... </p>
<div><a href="https://webmuch.com/how-to-insert-symfony2-captcha-to-login-page-in-fosuserbundle/" class="more-link">Read More</a></div>
<p>The post <a href="https://webmuch.com/how-to-insert-symfony2-captcha-to-login-page-in-fosuserbundle/">How To Insert Symfony2 Captcha To Login Page In FOSUserBundle</a> appeared first on <a href="https://webmuch.com">Webmuch</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Ever wonder why computers sometimes ask you to prove you’re human? When a user tries to login to a website and fails twice, the computer asks the user to enter some code which is readable by human only in the third attempt, this is done to check whether the user is a machine or a human. Since hacking has touched another level, captcha is used to check whether the system is being accessed by human or a bot. This is done by using captcha at the login panel.</p>
<p>It isn&#8217;t a hard job to add Symfony2 Captcha to the login panel.</p>
<h3>Adding Symfony2 Captcha To A Login Panel</h3>
<p>FOSUserBundle is concerned with user management and user security. It is not able to differentiate between a human and a robot and to put  this functionality in our “Symfony” application we have to add Symfony2 captcha in FOS Bundle&#8217;s login and registration page. Adding Symfony2 captcha in registration is easy, as we can add it simply in the “RegistrationType” file of FOSUserBundle but adding Symfony2 captcha in a login page is not as simple as on the registration page.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-15717" src="http://webmuch.com/wp-content/uploads/2015/02/D0k2R2.png" alt="D0k2R" width="376" height="479" srcset="https://webmuch.com/wp-content/uploads/2015/02/D0k2R2.png 376w, https://webmuch.com/wp-content/uploads/2015/02/D0k2R2-100x127.png 100w" sizes="auto, (max-width: 376px) 100vw, 376px" /></p>
<p>To go further, follow the steps below:</p>
<ul>
<li><strong>Download the CodeConsortium Bundle<br />
</strong>This is a private messaging system Bundle for Symfony projects for sending and receiving private messages.</li>
<li><strong>Add the Bundle in your project by adding the following code in the Appkernel.php file.</strong></li>
</ul>
<pre class="lang:default decode:true ">Webmuch/Acme/App/Appkernel.php :
“new CCDNUser\SecurityBundle\CCDNUserSecurityBundle(),”
</pre>
<p>&nbsp;</p>
<ul>
<li><strong>Add the following configuration in your config.yml file.</strong></li>
</ul>
<pre class="lang:default decode:true ">Webmuch/Acme/Config/Config.yml :
ccdn_user_security:
route_referer:
route_ignore_list:
- { bundle: 'fosuserbundle', route: 'fos_user_security_login' }
- { bundle: 'fosuserbundle', route: 'fos_user_security_check' }
- { bundle: 'fosuserbundle', route: 'fos_user_security_logout' }
- { bundle: 'fosuserbundle', route: 'fos_user_registration_register' }
- { bundle: 'fosuserbundle', route: 'fos_user_registration_check_email' }
- { bundle: 'fosuserbundle', route: 'fos_user_registration_confirm' }
- { bundle: 'fosuserbundle', route: 'fos_user_registration_confirmed' }
- { bundle: 'fosuserbundle', route: 'fos_user_resetting_request' }
- { bundle: 'fosuserbundle', route: 'fos_user_resetting_send_email' }
- { bundle: 'fosuserbundle', route: 'fos_user_resetting_check_email' }
- { bundle: 'fosuserbundle', route: 'fos_user_resetting_reset' }
- { bundle: 'fosuserbundle', route: 'fos_user_change_password' }
- { bundle: 'UserBundle', route: 'fos_user_captcha_login' }
- { bundle: 'UserBundle', route: 'fos_user_captcha_login_check' }
login_shield:
enable_shield: true
block_for_minutes: 5
limit_failed_login_attempts:
before_recover_account: 3
before_return_http_500: 25
primary_login_route:
name: fos_user_security_login
recover_account_route:
name: fos_user_captcha_login
block_routes_when_denied:
- fos_user_security_login
- fos_user_security_check
- fos_user_security_logout</pre>
<p>&nbsp;</p>
<p><strong>Below you&#8217;ll find the Pseudocode for the code above.</strong></p>
<p>The code below will cause the captcha image to be inserted on the login page if the first two attempts of login fail.</p>
<pre class="lang:default decode:true ">before_recover_account: 3:</pre>
<p>&nbsp;</p>
<p>This code below will cause the user to be blocked if it fails to login for 25 times in a row.</p>
<pre class="lang:default decode:true ">before_return_http_500: 25</pre>
<p>&nbsp;</p>
<p>The primary login route is defined for the default login page of the FOS UserBundle.<br />
The secondary or recover route is defined for the new login page including captcha which will be build later.</p>
<pre class="lang:default decode:true ">primary_login_route:
name: fos_user_security_login
recover_account_route:
name: fos_user_captcha_login</pre>
<p>&nbsp;</p>
<p>All the statements below will cause the login, logout and email check functionalities to be blocked if the user is not able to login.</p>
<pre class="lang:default decode:true ">block_routes_when_denied:
- fos_user_security_login
- fos_user_security_check
- fos_user_security_logout</pre>
<p>&nbsp;</p>
<ul>
<li>After setting all the configurations properly, the forth step is to create “usercaptchalogin” which <span style="line-height: 1.5;">will be built inside the UserController.php file :</span></li>
</ul>
<pre class="lang:default decode:true ">Webmuch/UserBundle/Controller/UserController</pre>
<p>&nbsp;</p>
<p>For this, we need to import the following statements on the top of the file “UserController.php” :</p>
<pre class="lang:default decode:true ">use Gregwar\Captcha\CaptchaBuilder;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;

. use Gregwar\Captcha\CaptchaBuilder;

</pre>
<p>All of the code above is to build the Captcha image dynamically on the login page and to authenticate the user credentials on the basis of username and password and for the interaction of user with various events.</p>
<p>Now, we define the following function inside the controller for creating the &#8220;usercaptchalogin&#8221; which will build the login page including Symfony2 captcha:</p>
<pre class="lang:default decode:true ">public function fosUserCaptchaLoginAction(){
$builtCaptcha = new CaptchaBuilder();
$builtCaptcha-&gt;build();
$builtCaptcha-&gt;save('captcha.jpg');
return $this-
&gt;render('UserBundle:CustomizedSecurity:fosUserCaptchaLogin.html.twig',array
('captcha' =&gt; $builtCaptcha)) }
</pre>
<p>&nbsp;</p>
<p>The code above is explained well in the steps below:</p>
<ol>
<li>The first statement will build a Symfony2 captcha image using the function CaptchaBuilder()</li>
<li>The next two statements will save the build image inside the variable “builtCaptcha” in a jpg format.</li>
<li>This image will then be rendered to CaptchaLogin.html.twig file which will be created later.</li>
</ol>
<p>We define another function inside the controller which will check or validate the value of Symfony2 captcha inserted :</p>
<pre class="lang:default decode:true ">public function fosUserCaptchaLoginCheckAction($builtCaptcha){
$em = $this-&gt;getDoctrine()-&gt;getEntityManager();
$username = $this-&gt;getRequest()-&gt;get('_username');
$password = $this-&gt;getRequest()-&gt;get('_password');
$captcha = $this-&gt;getRequest()-&gt;get('_captcha');
$email = $this-&gt;getRequest()-&gt;get('email');
$session = $this-&gt;get('session');
$result = $em-&gt;getRepository('UserBundle:User')-&gt;findOneBy(array('email' =&gt; $username));
if(!$result){
$this-&gt;get('session')-&gt;getFlashBag()-&gt;add('error','Username is wrong');
return $this-&gt;redirect($this-&gt;generateUrl('fos_user_captcha_login'));
}
if (isset($result)) {
$encoder_service = $this-&gt;get('security.encoder_factory');
$encoder = $encoder_service-&gt;getEncoder($result);
$encoded_pass = $encoder-&gt;encodePassword($password, $result-&gt;getSalt());
if($result-&gt;getPassword() !== $encoded_pass){
$this-&gt;get('session')-&gt;getFlashBag()-&gt;add('error','Password is wrong');
return $this-&gt;redirect($this-&gt;generateUrl('fos_user_captcha_login'));
}else{
if($builtCaptcha !== $captcha){
$this-&gt;get('session')-&gt;getFlashBag()-&gt;add('error','Captcha code is wrong');
return $this-&gt;redirect($this-&gt;generateUrl('fos_user_captcha_login'));
}else{
$firewall = "user_secured_area";
$token = new UsernamePasswordToken($result,$password, $firewall, $result- &gt;getRoles());
$this-&gt;get('security.context')-&gt;setToken($token);
$session = $this-&gt;get('session');
$session-&gt;set('_security_'.$firewall,serialize($token));
$event = new InteractiveLoginEvent($this-&gt;getRequest(), $token);
$this-&gt;get("event_dispatcher")-&gt;dispatch("security.interactive_login", $event);
$router = $this-&gt;get('router');
$url = $router-&gt;generate('video');
return $this-&gt;redirect($url);
}
}
}
$this-&gt;get('session')-&gt;getFlashBag()-&gt;add('error','Your entered value is wrong');
return $this-&gt;redirect($this-&gt;generateUrl('fos_user_captcha_login'));
}</pre>
<p>&nbsp;</p>
<p>The steps for the above mentioned code can be explained below:</p>
<ol>
<li>First we will get the values of various fields such as email, username, password and Symfony2 captcha.</li>
<li>After storing these values inside the result variable we will check for the username and if the username doesn&#8217;t match, the user will be renedred to the fos_user_captcha_login&#8217;.</li>
<li>If the values of username matches then it will proceed further to validate the password and the same will be done for validating Symfony2 captcha.</li>
</ol>
<p>The entire code of the UserController.php is given as follows :</p>
<pre class="lang:default decode:true  ">get('fos_facebook.user.login');
//todo: check if service is successfully connected.
$fbService-&gt;connectExistingAccount();
return $this-&gt;redirect($this-&gt;generateUrl('sonata_user_profile_visit'));
}
public function loginFbAction(){
return $this-&gt;redirect($this-&gt;generateUrl("fos_user_security_login"));
}
public function logoutFbAction(){
return $this-&gt;redirect($this-&gt;generateUrl("fos_user_security_logout"));
}
private function getToken(){
return new Response($this-&gt;container-&gt;get('form.csrf_provider')
-&gt;generateCsrfToken('authenticate'));
}
public function fosUserCaptchaLoginAction(){
$builtCaptcha = new CaptchaBuilder();
$builtCaptcha-&gt;build();
$builtCaptcha-&gt;save('captcha.jpg');
return $this- &gt;render('UserBundle:CustomizedSecurity:fosUserCaptchaLogin.html.twig',array('captcha' =&gt; $builtCaptcha));
}
public function fosUserCaptchaLoginCheckAction($builtCaptcha){
$em = $this-&gt;getDoctrine()-&gt;getEntityManager();
$username = $this-&gt;getRequest()-&gt;get('_username');
$password = $this-&gt;getRequest()-&gt;get('_password');
$captcha = $this-&gt;getRequest()-&gt;get('_captcha');
$email = $this-&gt;getRequest()-&gt;get('email');
$session = $this-&gt;get('session');
$result = $em-&gt;getRepository('UserBundle:User')-&gt;findOneBy(array('email' =&gt; $username));
if(!$result){
$this-&gt;get('session')-&gt;getFlashBag()-&gt;add('error','Username is wrong');
return $this-&gt;redirect($this-&gt;generateUrl('fos_user_captcha_login'));
}
if (isset($result)) {
$encoder_service = $this-&gt;get('security.encoder_factory');
$encoder = $encoder_service-&gt;getEncoder($result);
$encoded_pass = $encoder-&gt;encodePassword($password, $result-&gt;getSalt());
if($result-&gt;getPassword() !== $encoded_pass){
$this-&gt;get('session')-&gt;getFlashBag()-&gt;add('error','Password is wrong');
return $this-&gt;redirect($this-&gt;generateUrl('fos_user_captcha_login'));
}else{
if($builtCaptcha !== $captcha){
$this-&gt;get('session')-&gt;getFlashBag()-&gt;add('error','Captcha code is wrong');
return $this-&gt;redirect($this-&gt;generateUrl('fos_user_captcha_login'));
}else{
$firewall = "user_secured_area";
$token = new UsernamePasswordToken($result,$password, $firewall, $result- &gt;getRoles());
$this-&gt;get('security.context')-&gt;setToken($token);
$session = $this-&gt;get('session');
$session-&gt;set('_security_'.$firewall,serialize($token));
$event = new InteractiveLoginEvent($this-&gt;getRequest(), $token);
$this-&gt;get("event_dispatcher")-&gt;dispatch("security.interactive_login", $event);
$router = $this-&gt;get('router');
$url = $router-&gt;generate('video');
return $this-&gt;redirect($url);
}
}
}
$this-&gt;get('session')-&gt;getFlashBag()-&gt;add('error','Your entered value is wrong');
return $this-&gt;redirect($this-&gt;generateUrl('fos_user_captcha_login'));
}
public function emailAuthenticateAction(Request $request, $token){
$em = $this-&gt;getDoctrine()-&gt;getEntityManager();
$user = $em-&gt;getRepository('UserBundle:User')-&gt;findOneBy(array('token' =&gt; $token));
if(isset($user)) {
if($user-&gt;isEnabled() == false) {
// Enabling The Account
$user-&gt;setEnabled(true);
$user-&gt;setToken(null);
$em-&gt;persist($user);
$em-&gt;flush();
$this-&gt;authenticateUser($user);
$this-&gt;get('session')-&gt;getFlashBag()-&gt;add('success','Congratulation you are authenticated member of Candulife Style.');
return $this-&gt;redirect($this-&gt;generateUrl('home'));
}
}
$this-&gt;get('session')-&gt;getFlashBag()-&gt;add('error','This link is invalid or has been already used');
return $this-&gt;redirect($this-&gt;generateUrl('home'));
}
private function authenticateUser(UserInterface $user){
$provideKey = 'user_secured_area';
$token = new UsernamePasswordToken($user,$user-&gt;getPassword(),$provideKey,$user-&gt;getRoles());
$this-&gt;get('security.context')-&gt;setToken($token);
}
private function generateToken(){
$key = '#}~*$/"$?&amp;*(."*/[!%]/${"/}';
$unique = uniqid();
return $token = $unique.substr(hash('sha512',$unique.$key.microtime()), 0, 19);
}
}</pre>
<p>&nbsp;</p>
<ul>
<li>Fifth Step is to create “usercaptchalogin”  and then we will create “fosUserCaptchaLogin.html.twig” file where the user will be rendered for login purpose inside which captcha will be introduced after login will be failed two times continously.</li>
</ul>
<p>The code for the same is given as follows :</p>
<pre class="lang:default decode:true ">UserBundle/Resources/Views/Email/fosUserCaptchaLogin.html.twig :

{% extends "::base1.html.twig" %}

{% block userProfile %}
&lt;h2 class="gradWellHead"&gt;Login here {# count #}&lt;/h2&gt;
&lt;div class="row-fluid marginBottom10"&gt;
&lt;div class="span6 well"&gt;&lt;form action="{{ path(" method="post" novalidate="" data-validate="parsley"&gt;
&lt;div class="control-group"&gt;

&lt;label class="control-label" for="username"&gt;Username&lt;/label&gt;
&lt;div class="controls"&gt;&lt;input name="_username" required="required" type="text" placeholder="Username" data-error-message="Enter your Username" data-required="true" /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="control-group"&gt;

&lt;label class="control-label" for="password"&gt;Password&lt;/label&gt;
&lt;div class="controls"&gt;&lt;input name="_password" required="required" type="password" placeholder="Password" data-error-message="Enter the Password" data-required="true" /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="control-group"&gt;

&lt;label class="control-label" for="captcha"&gt;Captcha&lt;/label&gt;
&lt;div class="controls"&gt;&lt;img src="{{ asset('captcha.jpg') }}" alt="" /&gt;
&lt;input name="_captcha" required="required" type="text" placeholder="Captcha" data-error-message="Enter the Captcha code" data-required="true" /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="control-group"&gt;
&lt;div class="controls"&gt;&lt;label class="checkbox"&gt;
&lt;input id="remember_me" name="_remember_me" type="checkbox" value="on" /&gt;{{ 'security.login.remember_me'|trans({}, 'FOSUserBundle') }}
&lt;/label&gt;
&lt;input id="_submit" class="btn" name="_submit" type="submit" value="{{ 'security.login.submit'|trans({}, 'FOSUserBundle') }}" /&gt;
&lt;a href="{{ path('fos_user_resetting_request') }}"&gt;Forget Password ?&lt;/a&gt;
{{ facebook_login_button({'autologoutlink': true}) }}&lt;/div&gt;
&lt;/div&gt;
&lt;/form&gt;&lt;/div&gt;
&lt;div class="span6 well"&gt;&lt;img src="{{asset('img/candu_manifesto_starburst.jpg')}}" alt="" /&gt;&lt;/div&gt;
&lt;/div&gt;
{% endblock %}</pre>
<p>&nbsp;</p>
<p><img loading="lazy" decoding="async" class="aligncenter  wp-image-15718" src="http://webmuch.com/wp-content/uploads/2015/02/21.png" alt="2" width="558" height="270" srcset="https://webmuch.com/wp-content/uploads/2015/02/21.png 428w, https://webmuch.com/wp-content/uploads/2015/02/21-100x48.png 100w" sizes="auto, (max-width: 558px) 100vw, 558px" /></p>
<p>I got my Symfony2 Captcha correct, hope you get yours too.</p>
<p>Feel free to comment for any queries or doubts. Do subscribe to our newsletter if you appreciate the tutorial.</p>
<p><strong> </strong></p>
<h3 style="text-align: center;">FOR MORE AWESOME TUTORIALS:</h3>
<div  class="x-column x-sm x-1-2" style="" >
<h4 style="text-align: center;"><a href="http://webmuch.com/upgrade-bootstrap-2-twitter-bootstrap3-build/">How To Upgrade Bootstrap 2 To Twitter Bootstrap 3  Build</a></h4>
<p style="text-align: center;" ><a href="http://webmuch.com/upgrade-bootstrap-2-twitter-bootstrap3-build/"><img loading="lazy" decoding="async" class="  wp-image-15775 alignnone" src="http://webmuch.com/wp-content/uploads/2015/02/bootstrap2-Vs-3-Img.png" alt="bootstrap2 Vs 3 Img" width="250" height="215" srcset="https://webmuch.com/wp-content/uploads/2015/02/bootstrap2-Vs-3-Img.png 986w, https://webmuch.com/wp-content/uploads/2015/02/bootstrap2-Vs-3-Img-100x86.png 100w, https://webmuch.com/wp-content/uploads/2015/02/bootstrap2-Vs-3-Img-979x841.png 979w" sizes="auto, (max-width: 250px) 100vw, 250px" /></a></p>
</div>
<div  class="x-column x-sm x-1-2 last" style="" >
<h4 style="text-align: center;"><a href="http://webmuch.com/embed-eav-model-symfony2-collection-form/">How To Embed EAV Model In Symfony2 Collection Form<br />
</a></h4>
<p style="text-align: center;" ><a href="http://webmuch.com/embed-eav-model-symfony2-collection-form/"><img loading="lazy" decoding="async" class="  wp-image-15725 alignnone" src="http://webmuch.com/wp-content/uploads/2015/02/newfeatimagecollection.png" alt="newfeatimagecollection" width="266" height="166" srcset="https://webmuch.com/wp-content/uploads/2015/02/newfeatimagecollection.png 800w, https://webmuch.com/wp-content/uploads/2015/02/newfeatimagecollection-100x63.png 100w" sizes="auto, (max-width: 266px) 100vw, 266px" /></a></p>
</div>
<div  class="x-column x-sm x-1-2" style="" >
<h4 style="text-align: center;"><a href="http://webmuch.com/override-fosuserbundle/">How To Override FOSUser Bundle<br />
</a></h4>
<p style="text-align: center;" ><a href="http://webmuch.com/override-fosuserbundle/"><img loading="lazy" decoding="async" class="  wp-image-15674 alignnone" src="http://webmuch.com/wp-content/uploads/2015/02/symfonyplusfos.png" alt="symfonyplusfos" width="288" height="216" srcset="https://webmuch.com/wp-content/uploads/2015/02/symfonyplusfos.png 638w, https://webmuch.com/wp-content/uploads/2015/02/symfonyplusfos-100x75.png 100w" sizes="auto, (max-width: 288px) 100vw, 288px" /></a></p>
</div>
<div  class="x-column x-sm x-1-2 last" style="" >
<h4 style="text-align: center;"><a href="http://webmuch.com/create-multi-column-design-layout-using-wookmark-jquery/">How To Create A Multi Column Design Layout Using Wookmark jQuery</a></h4>
<p style="text-align: center;" ><a href="http://webmuch.com/create-multi-column-design-layout-using-wookmark-jquery/"><img loading="lazy" decoding="async" class="  wp-image-15389 alignnone" src="http://webmuch.com/wp-content/uploads/2015/01/jquery-wookmark-1.jpg" alt="wookmark jquery" width="309" height="157" srcset="https://webmuch.com/wp-content/uploads/2015/01/jquery-wookmark-1.jpg 750w, https://webmuch.com/wp-content/uploads/2015/01/jquery-wookmark-1-100x51.jpg 100w" sizes="auto, (max-width: 309px) 100vw, 309px" /></a></p>
</div>
<p>The post <a href="https://webmuch.com/how-to-insert-symfony2-captcha-to-login-page-in-fosuserbundle/">How To Insert Symfony2 Captcha To Login Page In FOSUserBundle</a> appeared first on <a href="https://webmuch.com">Webmuch</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://webmuch.com/how-to-insert-symfony2-captcha-to-login-page-in-fosuserbundle/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How To Upgrade Bootstrap 2 To Twitter Bootstrap 3 Build</title>
		<link>https://webmuch.com/upgrade-bootstrap-2-twitter-bootstrap3-build/</link>
					<comments>https://webmuch.com/upgrade-bootstrap-2-twitter-bootstrap3-build/#respond</comments>
		
		<dc:creator><![CDATA[Jojo]]></dc:creator>
		<pubDate>Sat, 21 Feb 2015 11:36:15 +0000</pubDate>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[htmlui]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Bootstrap]]></category>
		<category><![CDATA[Bootstrap2]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Glyphicons]]></category>
		<category><![CDATA[Twitter Bootstrap3]]></category>
		<guid isPermaLink="false">http://webmuch.com/?p=15594</guid>

					<description><![CDATA[<p>Introducing  Twitter Bootstrap 3 with it&#8217;s new advanced features The  Twitter Bootstrap 3 framework is an awesome and  powerful tool to develop frontend user interfaces for web applications.  Twitter Bootstrap 3 is a simple and flexible HTML, CSS, JavaScript and jQuery plugins framework for popular user interface components. Bootstrap makes it easy to create good-looking web pages and web-apps, plus it has ... </p>
<div><a href="https://webmuch.com/upgrade-bootstrap-2-twitter-bootstrap3-build/" class="more-link">Read More</a></div>
<p>The post <a href="https://webmuch.com/upgrade-bootstrap-2-twitter-bootstrap3-build/">How To Upgrade Bootstrap 2 To Twitter Bootstrap 3 Build</a> appeared first on <a href="https://webmuch.com">Webmuch</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h3>Introducing  Twitter Bootstrap 3 with it&#8217;s new advanced features</h3>
<p>The  Twitter <strong>Bootstrap 3 framework</strong> is an awesome and  powerful tool to develop frontend user interfaces for web applications.  Twitter Bootstrap 3 is a simple and flexible HTML, CSS, JavaScript and jQuery plugins framework for popular user interface components. Bootstrap makes it easy to create good-looking web pages and web-apps, plus it has a &#8216;responsive grid&#8217; built-in automatically to make designs compatible with mobile browsers (both tablets and smartphones).</p>
<p>&nbsp;</p>
<p><img loading="lazy" decoding="async" class="aligncenter  wp-image-15737" src="http://webmuch.com/wp-content/uploads/2015/02/bootstrap.png" alt="bootstrap" width="305" height="305" srcset="https://webmuch.com/wp-content/uploads/2015/02/bootstrap.png 280w, https://webmuch.com/wp-content/uploads/2015/02/bootstrap-100x100.png 100w" sizes="auto, (max-width: 305px) 100vw, 305px" /></p>
<h3>A couple weeks  ago the developers of Bootstrap made a major update moving from 2.3.2 to version 3.32</h3>
<p>Twitter Bootstrap 3 has major changes from all it&#8217;s past versions. It is a <strong>mobile-first framework </strong><span style="text-decoration: underline;"> and makes your site &#8220;always responsive&#8221; by default, whatever you design or create will be mobile compatible or responsive.</span></p>
<p>Twitter Bootstrap 3 is one of the best CSS frameworks for building responsive website designs..</p>
<p>So now, take a look at the major difference between Bootstrap 2 vs Twitter Bootstrap 3.</p>
<p><strong><span style="text-decoration: underline;">Bootstrap 2</span></strong><br />
Span method is used to create columns.<br />
<span style="line-height: 1.5;">It does not support mobile-first.<br />
</span><span style="line-height: 1.5;">Container and Container-fluid </span><span style="line-height: 1.5;">class are used.<br />
</span><span style="line-height: 1.5;">Bootstrap 2 meta tag:&lt;meta name=&#8221;</span>viewport&#8221; content =&#8221;width =device-width,initial-scale=1.0&#8243;&gt;</p>
<p><span style="text-decoration: underline;"><strong>Twitter Bootstrap 3<br />
</strong></span>Col method is used to create columns.<br />
It support mobile first framework.<br />
They used container class.<br />
Bootstrap 3 meta tag :&lt;meta name =&#8221;viewport&#8221; content=width=device-width, initial- scale= &#8220;1.0&#8221;&gt;</p>
<p><b><span style="text-decoration: underline;">Note</span><br />
</b>If we want to update the legacy bootstrap build to  Twitter Bootstrap 3, we need to change the HTML code from span to col (columns) methodology. And for updating the legacy bootstrap build, we are going to update it as per &#8220;mobile first framework&#8221; by using bootstrap 3 mobile class (xs and sm).</p>
<p>&nbsp;</p>
<h3>Different versions of Ajax Library are used to enable the jQuery functionality in Bootstrap</h3>
<p>&nbsp;</p>
<p><b>***</b><b>Ajax library update for bootstrap 2:</b></p>
<p>JQuery v1.7.1 jquery.co</p>
<p><b>Ajax library update for bootstrap </b><b>3</b><b>: </b></p>
<p>JQuery v1.9.0+ jquery.com (see: <a href="https://www.drupal.org/node/2245299">#2245299: minimum jQuery version is 1.9.0 for Bootstrap 3.1.1</a>)</p>
<p><b><span style="text-decoration: underline;">Note</span><br />
</b>The project page should be updated to point users to find the current minimum version of jQuery needed for the latest Bootstrap.</p>
<p>In legacy bootstrap 2, we use live or delegate method, and then we change the method to “ON” because after jQuery 1.9.1 the &#8216;live&#8217; or&#8221; delegate&#8221; method is deprecated by &#8220;ON&#8217; method.</p>
<p>&nbsp;</p>
<h3><strong>GLYPHICONS</strong></h3>
<p>&#8220;Glyphicons &#8221; is a library of properly prepared monochromatic icons and symbols, created with an emphasis on simplicity and easy orientation.</p>
<p><b><strong> So, now these are the certain changes that have been made in the Glyphicons</strong></b></p>
<p>In bootstrap 2, you have 140 icon glyphs in spirit form, available in dark gray (default) and white provided by Glyphicons.</p>
<p><img loading="lazy" decoding="async" class="aligncenter  wp-image-15738" src="http://webmuch.com/wp-content/uploads/2015/02/glyphicons-3.jpg" alt="glyphicons 3" width="444" height="415" srcset="https://webmuch.com/wp-content/uploads/2015/02/glyphicons-3.jpg 232w, https://webmuch.com/wp-content/uploads/2015/02/glyphicons-3-100x94.jpg 100w" sizes="auto, (max-width: 444px) 100vw, 444px" /></p>
<p>In order to upgrade Bootstrap build you have to change the &#8220;glyphicon&#8221;. While the Twitter Bootstrap 3 has included 260 glyphs in font format from the Glyphicon Halfing Set.</p>
<p>&nbsp;</p>
<h3>For running Bootstrap website in IE</h3>
<p>&lt;!&#8211;[if lt IE 8]&gt;</p>
<p>&lt;link href=&#8221;css/bootstrap-ie7fix.min.css&#8221; rel=&#8221;stylesheet&#8221;&gt;</p>
<p>&lt;![endif]&#8211;&gt;</p>
<h3>Updating process:</h3>
<ol>
<li>Adding bootstrap-responsive.css in your application.</li>
<li>Twitter Bootstrap 3: The .container &amp; .row classes are now fluid by default, so it does not use -row fluid or container fluid anymore in your 3x. markup.</li>
</ol>
<h4>Grid Migration</h4>
<p>How to convert from a 2.x to 3.0 grid <i>without</i> any responsive changes.</p>
<ul>
<li>replace .container-fluidwith .container.</li>
<li>replace .row-fluidwith .row.</li>
<li>replace .span*with .col-md-*</li>
</ul>
<p>While the Twitter Bootstrap 3 large grid (.col-md) are similar to the 2.x (span) grid, non form containers do not utilise the new responsive improvements in Bootstrap 3. If you want to &#8220;get more responsive&#8221; use the col-xs (tiny),col sm-(small) and col-lg(large) classes for better scaling on smartphones and tablets. Now you can use 3 different grid sizes, to exclude the vertical stack on smaller sizes.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-16024 size-full" src="http://webmuch.com/wp-content/uploads/2015/02/bootstarpfeat.jpg" alt="" width="638" height="479" srcset="https://webmuch.com/wp-content/uploads/2015/02/bootstarpfeat.jpg 638w, https://webmuch.com/wp-content/uploads/2015/02/bootstarpfeat-100x75.jpg 100w" sizes="auto, (max-width: 638px) 100vw, 638px" /></p>
<h4>Navbar Migration</h4>
<p>How to convert from a 2.x to 3.0 navbar</p>
<ul>
<li>remove .navbar-inner</li>
<li>replace .brandwith .navbar-brand</li>
<li>wrap .navbar-brandand .navbar-toggle inside .navbar-header</li>
<li>add .navbar-navto .nav</li>
</ul>
<p>So there are also some changes in Navbar migration. The &#8220;.brand&#8221; is replacing with the &#8220;navbar-brand&#8221;. It is used to define the links.</p>
<h3>Modal Migration</h3>
<p>How to convert from a 2.x to 3.0 modal</p>
<ul>
<li>remove.hide from the .modal (it&#8217;s now hidden by default)</li>
<li>wrap.modal-header .modal-body .modal-footer inside .modal-content</li>
<li>wrap.modal-content inside .modal-dialog</li>
</ul>
<h2>Twitter Bootstrap 3 Migration Guide</h2>
<p>You can use this block as a general migration guide to upgrading from v2.x to v3.0.</p>
<h3>Major CSS Class Changes</h3>
<p><img loading="lazy" decoding="async" class="aligncenter  wp-image-15740" src="http://webmuch.com/wp-content/uploads/2015/02/bootstrap-classes.jpg" alt="bootstrap classes" width="441" height="233" /></p>
<p>A consistent design in  Twitter Bootstrap 3 is the use of “base” CSS class names that provide a default for elements. The following  table shows the CSS style changes between v2.x and v3.0.</p>
<table>
<tbody>
<tr>
<td width="264"><b>Bootstrap 2.x</b></td>
<td width="370"><b>Bootstrap 3.0</b></td>
</tr>
<tr>
<td width="264">.container-fluid</td>
<td width="370">.container</td>
</tr>
<tr>
<td width="264">.row-fluid</td>
<td width="370">.row</td>
</tr>
<tr>
<td width="264">.span*</td>
<td width="370">.col-md-*</td>
</tr>
<tr>
<td width="264">.offset*</td>
<td width="370">.col-md-offset-*</td>
</tr>
<tr>
<td width="264">.brand</td>
<td width="370">.navbar-brand</td>
</tr>
<tr>
<td width="264">.hero-unit</td>
<td width="370">.jumbotron</td>
</tr>
<tr>
<td width="264">.icon-*</td>
<td width="370">.glyphicon .glyphicon-*</td>
</tr>
<tr>
<td width="264">.btn</td>
<td width="370">.btn .btn-default</td>
</tr>
<tr>
<td width="264">.btn-mini</td>
<td width="370">.btn-xs</td>
</tr>
<tr>
<td width="264">.btn-small</td>
<td width="370">.btn-sm</td>
</tr>
<tr>
<td width="264">.btn-large</td>
<td width="370">.btn-lg</td>
</tr>
<tr>
<td width="264">.visible-phone</td>
<td width="370">.visible-sm</td>
</tr>
<tr>
<td width="264">.visible-tablet</td>
<td width="370">.visible-md</td>
</tr>
<tr>
<td width="264">.visible-desktop</td>
<td width="370">.visible-lg</td>
</tr>
<tr>
<td width="264">.hidden-phone</td>
<td width="370">.hidden-sm</td>
</tr>
<tr>
<td width="264">.hidden-tablet</td>
<td width="370">.hidden-md</td>
</tr>
<tr>
<td width="264">.hidden-desktop</td>
<td width="370">.hidden-lg</td>
</tr>
<tr>
<td width="264">.input-small</td>
<td width="370">.input-sm</td>
</tr>
<tr>
<td width="264">.input-large</td>
<td width="370">.input-lg</td>
</tr>
<tr>
<td width="264">.input-prepend</td>
<td width="370">.input-group</td>
</tr>
<tr>
<td width="264">.input-append</td>
<td width="370">.input-group</td>
</tr>
<tr>
<td width="264">.add-on</td>
<td width="370">.input-group-addon</td>
</tr>
<tr>
<td width="264">.btn-navbar</td>
<td width="370">.navbar-btn</td>
</tr>
<tr>
<td width="264">.thumbnail</td>
<td width="370">.img-thumbnail</td>
</tr>
<tr>
<td width="264">ul.inline</td>
<td width="370">.list-inline</td>
</tr>
</tbody>
</table>
<p>You can see the above table, &#8220;container-fluid &#8221; and &#8220;row-fluid&#8221;  classes are now container and row. There is no more &#8220;span&#8221;. There is now base column unit named &#8220;col-md&#8221; that is sized using &#8220;col-lg-&#8220;. So instead of span2, you’d now use col-lg-2. This also works for offsets, so offset is now col- md-offset and so on.<br />
<strong> </strong></p>
<h3>The elements in  Twitter bootstrap 3 which are removed by bootstrap 2</h3>
<p>Below are those elements which have been released or changed in v3. For example, hero unit is removed from 2.x and added in 3.0 with its new name called jumbotron.</p>
<table>
<tbody>
<tr>
<td width="155"><b> </b><b>Element</b></td>
<td width="244"><b>Removed from 2.x</b></td>
<td width="208"><b>3.0 Equivalent</b></td>
</tr>
<tr>
<td width="155">Hero Unit</td>
<td width="244">.hero-unit</td>
<td width="208">.jumbotron</td>
</tr>
<tr>
<td width="155">Form actions</td>
<td width="244">.form-actions</td>
<td width="208">&#8211;</td>
</tr>
<tr>
<td width="155">Grid</td>
<td width="244">.span*</td>
<td width="208">.col-md-*</td>
</tr>
<tr>
<td width="155">Fluid container</td>
<td width="244">.container-fluid</td>
<td width="208">.container (no more fixed grid)</td>
</tr>
<tr>
<td width="155">Fluid row</td>
<td width="244">.row-fluid</td>
<td width="208">.row (no more fixed grid)</td>
</tr>
<tr>
<td width="155">Icons</td>
<td width="244">.icon-*</td>
<td width="208">.glyphicon-*</td>
</tr>
<tr>
<td width="155">Navbar button</td>
<td width="244">.btn-navbar</td>
<td width="208">.navbar-btn</td>
</tr>
<tr>
<td width="155">Navbar inner</td>
<td width="244">.navbar-inner</td>
<td width="208">&#8211;</td>
</tr>
<tr>
<td width="155">Nav list</td>
<td width="244">.nav-list</td>
<td width="208">.list-group</td>
</tr>
<tr>
<td width="155">Thumbnails</td>
<td width="244">.thumbnails</td>
<td width="208">.col-* and .thumbnail</td>
</tr>
<tr>
<td width="155">Input append / prepend</td>
<td width="244">.input-append .input-prepend .add-on</td>
<td width="208">.input-group</td>
</tr>
<tr>
<td width="155">Dropdown submenu</td>
<td width="244">.dropdown-submenu</td>
<td width="208">&#8211;</td>
</tr>
<tr>
<td width="155">Tab alignments</td>
<td width="244">.tabs-left .tabs-right .tabs-below</td>
<td width="208">&#8211;</td>
</tr>
</tbody>
</table>
<table>
<tbody>
<tr>
<td width="125">Form actions</td>
<td width="188">.form-actions</td>
<td width="303">N/A</td>
</tr>
<tr>
<td width="125">Search form</td>
<td width="188">.form-search</td>
<td width="303">N/A</td>
</tr>
<tr>
<td width="125">Form group with info</td>
<td width="188">.control-group.info</td>
<td width="303">N/A</td>
</tr>
<tr>
<td width="125">Fluid container</td>
<td width="188">.container-fluid</td>
<td width="303">.container (no more fixed grid)</td>
</tr>
<tr>
<td width="125">Fluid row</td>
<td width="188">.row-fluid</td>
<td width="303">.row (no more fixed grid)</td>
</tr>
<tr>
<td width="125">Controls wrapper</td>
<td width="188">.controls</td>
<td width="303">N/A</td>
</tr>
<tr>
<td width="125">Controls row</td>
<td width="188">.controls-row</td>
<td width="303">.row or .form-group</td>
</tr>
<tr>
<td width="125">Navbar inner</td>
<td width="188">.navbar-inner</td>
<td width="303"><b>N/A</b></td>
</tr>
<tr>
<td width="125">Navbar vertical dividers</td>
<td width="188">.navbar .divider-vertical</td>
<td width="303">N/A</td>
</tr>
<tr>
<td width="125">Dropdown submenu</td>
<td width="188">.dropdown-submenu</td>
<td width="303">N/A</td>
</tr>
<tr>
<td width="125">Tab alignments</td>
<td width="188">.tabs-left .tabs-right.tabs-below</td>
<td width="303">N/A</td>
</tr>
<tr>
<td width="125">Nav lists</td>
<td width="188">.nav-list .nav-header</td>
<td width="303">No direct equivalent, but <a href="#list-group">list groups</a> and <a href="#collapse">.panel-groups</a> are similar.</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<h3> Twitter bootstrap 3 Additional Information</h3>
<ul>
<li><a href="http://www.bootply.com/bootstrap-3-migration-guide">Notes &amp; Caveats</a></li>
<li>.input-*are 100% width. Wrap inputs inside &lt;div class=&#8217;col-md-*&#8217;&gt;&lt;/div&gt; to control input widths.</li>
<li>.badgeno longer has contextual (-success,-primary,etc..) classes</li>
<li>.btnmust also use .btn-default to get the &#8216;default&#8217; button</li>
<li>.containerand .row are now fluid (percentage-based)</li>
<li>Images are not responsive by default. Use.img-responsive for fluid IMG size</li>
<li>Include.glyphicon base class in all icons (ie: .glyphicon .glyphicon-asterisk).</li>
</ul>
<p>For updating to Twitter Bootstrap 3 and running a responsive website successfully in IE, we need to add the &#8220;Respond.js&#8221; to enable media query.</p>
<table>
<tbody>
<tr>
<td width="111"><b>Feature</b></td>
<td colspan="2" width="139"><b>Internet Explorer 8</b></td>
<td width="181"><b>Internet Explorer 9</b></td>
</tr>
<tr>
<td width="111">border-radius</td>
<td colspan="2" width="139"> Not supported</td>
<td width="181"> Supported</td>
</tr>
<tr>
<td width="111">box-shadow</td>
<td colspan="2" width="139"> Not supported</td>
<td width="181"> Supported</td>
</tr>
<tr>
<td width="111">transform</td>
<td colspan="2" width="139"> Not supported</td>
<td width="181"> Supported, with -ms prefix</td>
</tr>
<tr>
<td colspan="2" width="181">transition</td>
<td colspan="2" width="251"> Not supported</td>
</tr>
<tr>
<td colspan="2" width="181">placeholder</td>
<td colspan="2" width="251"> Not supported</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<h3>Major CSS Changes</h3>
<table>
<tbody>
<tr>
<td width="220"><a href="http://upgrade-bootstrap.bootply.com/">Bootstrap 2.x</a></td>
<td width="297"><a href="http://upgrade-bootstrap.bootply.com/">Bootstrap 3.0</a></td>
</tr>
<tr>
<td width="220">.container-fluid</td>
<td width="297">.container</td>
</tr>
<tr>
<td width="220">.row-fluid</td>
<td width="297">.row</td>
</tr>
<tr>
<td width="220">.span*</td>
<td width="297">.col-md-*</td>
</tr>
<tr>
<td width="220">.offset*</td>
<td width="297">.col-md-offset-*</td>
</tr>
<tr>
<td width="220">.brand</td>
<td width="297">.navbar-brand</td>
</tr>
<tr>
<td width="220">.navbar .nav</td>
<td width="297">.nav .navbar-nav</td>
</tr>
<tr>
<td width="220">.hero-unit</td>
<td width="297">.jumbotron</td>
</tr>
<tr>
<td width="220">.icon-*</td>
<td width="297">.glyphicon .glyphicon-*</td>
</tr>
<tr>
<td width="220">.btn</td>
<td width="297">.btn .btn-default</td>
</tr>
<tr>
<td width="220">.btn-mini</td>
<td width="297">.btn-xs</td>
</tr>
<tr>
<td width="220">.btn-small</td>
<td width="297">.btn-sm</td>
</tr>
<tr>
<td width="220">.btn-large</td>
<td width="297">.btn-lg</td>
</tr>
<tr>
<td width="220">.visible-phone</td>
<td width="297">.visible-sm</td>
</tr>
<tr>
<td width="220">.visible-tablet</td>
<td width="297">.visible-md</td>
</tr>
<tr>
<td width="220">.visible-desktop</td>
<td width="297">.visible-lg</td>
</tr>
<tr>
<td width="220">.hidden-phone</td>
<td width="297">.hidden-sm</td>
</tr>
<tr>
<td width="220">.hidden-tablet</td>
<td width="297">.hidden-md</td>
</tr>
<tr>
<td width="220">.hidden-desktop</td>
<td width="297">.hidden-lg</td>
</tr>
<tr>
<td width="220">.input-prepend</td>
<td width="297">.input-group</td>
</tr>
<tr>
<td width="220">.input-append</td>
<td width="297">.input-group</td>
</tr>
<tr>
<td width="220">.add-on</td>
<td width="297">.input-group-addon</td>
</tr>
<tr>
<td width="220">.btn-navbar</td>
<td width="297">.navbar-btn</td>
</tr>
<tr>
<td width="220">.thumbnail</td>
<td width="297">.img-thumbnail</td>
</tr>
</tbody>
</table>
<h3></h3>
<h3>Lightweight</h3>
<p>Unlike version 2, all the icons are now contained in a separate CSS file. The CSS has been increased for performance as its size is approx 79kb. In CSS terms, the new Twitter Bootstrap 3 allows for easier customization by improving on inheritance and specificity. We don&#8217;t need to understand the fore mentioned, but realise that Twitter Bootstrap 3 does require more mark up in our HTML. In the end, it will means less customisation and CSS overrides to achieve what we want. Also, all the CSS classes for Twitter Bootstrap 3 are included in a single file.</p>
<p>For any doubts and queries, feel free to leave comments below. Remember to subscribe to our newsletter. Do share the tutorial if you think it&#8217;s worth it.</p>
<p>Cheers!</p>
<h3 style="text-align: center;">MORE AWESOME TUTORIALS</h3>
<div  class="x-column x-sm x-1-2" style="" >
<h4 style="text-align: center;"><a href="http://webmuch.com/embed-eav-model-symfony2-collection-form/">How To Embed EAV Model In Symfony2 Collection Form &#8211; TUTORIAL</a></h4>
<p style="text-align: center;"><a href="http://webmuch.com/embed-eav-model-symfony2-collection-form/"><img loading="lazy" decoding="async" class="alignnone wp-image-15725" src="http://webmuch.com/wp-content/uploads/2015/02/newfeatimagecollection.png" alt="newfeatimagecollection" width="250" height="156" srcset="https://webmuch.com/wp-content/uploads/2015/02/newfeatimagecollection.png 800w, https://webmuch.com/wp-content/uploads/2015/02/newfeatimagecollection-100x63.png 100w" sizes="auto, (max-width: 250px) 100vw, 250px" /></a></p>
</div>
<div  class="x-column x-sm x-1-2 last" style="" >
<h4 style="text-align: center;"><a href="http://webmuch.com/override-fosuserbundle/">How To Override FOSUserBundle &#8211; TUTORIAL<br />
</a></h4>
<p style="text-align: center;"><a href="http://webmuch.com/override-fosuserbundle/" rel="attachment wp-att-15674"><img loading="lazy" decoding="async" class="alignnone wp-image-15674" src="http://webmuch.com/wp-content/uploads/2015/02/symfonyplusfos.png" alt="symfonyplusfos" width="250" height="188" srcset="https://webmuch.com/wp-content/uploads/2015/02/symfonyplusfos.png 638w, https://webmuch.com/wp-content/uploads/2015/02/symfonyplusfos-100x75.png 100w" sizes="auto, (max-width: 250px) 100vw, 250px" /></a></div>
<div  class="x-column x-sm x-1-2" style="" >
<h4 style="text-align: center;"><a href="http://webmuch.com/create-multi-column-design-layout-using-wookmark-jquery/">How To Create A Multi Column Design Layout Using Wookmark jQuery &#8211; TUTORIAL</a></h4>
<p style="text-align: center;"><a href="http://webmuch.com/create-multi-column-design-layout-using-wookmark-jquery/" rel="attachment wp-att-15389"><img loading="lazy" decoding="async" class="alignnone wp-image-15389" src="http://webmuch.com/wp-content/uploads/2015/01/jquery-wookmark-1.jpg" alt="wookmark jquery" width="250" height="127" srcset="https://webmuch.com/wp-content/uploads/2015/01/jquery-wookmark-1.jpg 750w, https://webmuch.com/wp-content/uploads/2015/01/jquery-wookmark-1-100x51.jpg 100w" sizes="auto, (max-width: 250px) 100vw, 250px" /></a></div>
<div  class="x-column x-sm x-1-2 last" style="" >
<h4 style="text-align: center;"><a href="http://webmuch.com/create-business-application-data-grid-oro-platform/">How To Create A Business Application In Data Grid &#8211; ORO Platform &#8211; TUTORIAL</a></h4>
<p style="text-align: center;"><a href="http://webmuch.com/create-business-application-data-grid-oro-platform/"><img loading="lazy" decoding="async" class="alignnone wp-image-15379" src="http://webmuch.com/wp-content/uploads/2015/01/oro-plateform-1.jpg" alt="Oro Platform" width="250" height="112" srcset="https://webmuch.com/wp-content/uploads/2015/01/oro-plateform-1.jpg 1119w, https://webmuch.com/wp-content/uploads/2015/01/oro-plateform-1-100x45.jpg 100w, https://webmuch.com/wp-content/uploads/2015/01/oro-plateform-1-979x437.jpg 979w" sizes="auto, (max-width: 250px) 100vw, 250px" /></a></div>
<p>The post <a href="https://webmuch.com/upgrade-bootstrap-2-twitter-bootstrap3-build/">How To Upgrade Bootstrap 2 To Twitter Bootstrap 3 Build</a> appeared first on <a href="https://webmuch.com">Webmuch</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://webmuch.com/upgrade-bootstrap-2-twitter-bootstrap3-build/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How To Embed EAV Model In Symfony2 Collection Form</title>
		<link>https://webmuch.com/embed-eav-model-symfony2-collection-form/</link>
					<comments>https://webmuch.com/embed-eav-model-symfony2-collection-form/#respond</comments>
		
		<dc:creator><![CDATA[Jojo]]></dc:creator>
		<pubDate>Tue, 17 Feb 2015 10:00:41 +0000</pubDate>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[symfonyeav]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[AjaxAction]]></category>
		<category><![CDATA[Collection Form]]></category>
		<category><![CDATA[CRUD]]></category>
		<category><![CDATA[doctrine2]]></category>
		<category><![CDATA[EAV Model]]></category>
		<category><![CDATA[Symfony2]]></category>
		<category><![CDATA[symfony2 collection form]]></category>
		<guid isPermaLink="false">http://webmuch.com/?p=15399</guid>

					<description><![CDATA[<p>Today we are going to embed EAV(Entity Attribute Value) model using Symfony2 Collection Form component. Collection Form in Symfony2 means that a specific form field needs to be used to take multiple values by duplicating the field as many times as needed. The above explained feature of Symfony2 was used to create dynamic generation &#38; removal of specific form fields through ... </p>
<div><a href="https://webmuch.com/embed-eav-model-symfony2-collection-form/" class="more-link">Read More</a></div>
<p>The post <a href="https://webmuch.com/embed-eav-model-symfony2-collection-form/">How To Embed EAV Model In Symfony2 Collection Form</a> appeared first on <a href="https://webmuch.com">Webmuch</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Today we are going to embed <strong>EAV(Entity Attribute Value)</strong> model using Symfony2 Collection Form component. Collection Form in Symfony2 means that a specific form field needs to be used to take multiple values by duplicating the field as many times as needed.</p>
<p>The above explained feature of Symfony2 was used to create dynamic generation &amp; removal of specific form fields through collections for one of our client&#8217;s projection. In Symfony2 Collection Form, you must specify the type of the field and notify the form that it is the collection of the particular field.</p>
<p>This is done when you want to customize the Collection Form to the particular data that was submitted by the user.</p>
<p><a href="http://webmuch.com/how-to-create-symfony2-collection-form-using-symfony2-form-component/images-5-2/" rel="attachment wp-att-15383"><img loading="lazy" decoding="async" class="alignleft wp-image-15383" src="http://webmuch.com/wp-content/uploads/2015/01/images-5.jpg" alt="images (5)" width="400" height="200" srcset="https://webmuch.com/wp-content/uploads/2015/01/images-5.jpg 318w, https://webmuch.com/wp-content/uploads/2015/01/images-5-100x50.jpg 100w" sizes="auto, (max-width: 400px) 100vw, 400px" /></a></p>
<p>There is a requirement that on selecting a particular category form (add products) button, the list of all subcategories defined in the category should be displayed. So that the user can select one or multiple subcategory(s) form list of a particular category. Doctrine2 helps generate model classes from already existing databases.</p>
<p>One category can be mapped with many subcategories. For the form registration, the user can select as many categories and its corresponding subcategories.</p>
<p>For using Doctrine2 ORM, you&#8217;ll need to add the Doctrine2 metadata like using the One-To-Many relationship annotation, many subcategories can be mapped into one category. The user selects his choice of category and hence, it&#8217;s subcategories while filling up the form.</p>
<p>Yeah! EAV Model can be quite confusing, but it&#8217;s not that hard. You&#8217;ll get it right!</p>
<p><a href="http://webmuch.com/how-to-create-symfony2-collection-form-using-symfony2-form-component/doctrine2/" rel="attachment wp-att-15382"><img loading="lazy" decoding="async" class="alignleft wp-image-15382" src="http://webmuch.com/wp-content/uploads/2015/01/doctrine2.png" alt="doctrine2" width="250" height="54" srcset="https://webmuch.com/wp-content/uploads/2015/01/doctrine2.png 190w, https://webmuch.com/wp-content/uploads/2015/01/doctrine2-100x22.png 100w" sizes="auto, (max-width: 250px) 100vw, 250px" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h3><span style="text-decoration: underline;">Concept:</span></h3>
<p>First of all, we created three entities namely <strong>TrademarkQuestionnaire, Category, Subcategory.</strong> Here <strong>&#8220;TrademarkQuestionnaire&#8221;  -&gt; &#8220;Entity&#8221;, &#8220;Category&#8221; -&gt;  &#8220;Attribute&#8221;  and &#8220;SubCategory&#8221; -&gt; &#8220;Value&#8221;.</strong></p>
<p>We create a Category.php and SubCategory.php. Category and SubCategory has one-to-many relationship. Then we combine both of these <strong>Category</strong> and <strong>SubCategory</strong> in another entity class called <strong>CategorySubCategory.php. </strong>In this <strong>CategorySubCategory</strong> class <strong>Category</strong> and <strong>CategorySubCategory</strong> is mapped by <strong>one-to-many</strong> bidirectional relationship and <strong>CategorySubCategory</strong> and <strong>SubCategory</strong> class has <strong>one-to-many</strong> bidirectional relationship. Now in our main Entity class <strong>Trademarkquesionnaire.php</strong> we map Trademarkquesionnaire class with combined class entity <strong>CategorySubCategory</strong> class with <strong>many-to-many</strong> bidirectional relationship. Thus, we are able to embed <strong>EAV</strong> system using Symfony2 Collection Form.</p>
<h3><span style="text-decoration: underline;">Description</span></h3>
<h3>Entities</h3>
<p><b>Steps for creating the category entity and mapping of different fields of this entity with others:</b></p>
<p><span style="text-decoration: underline;"><strong>Create a category entity as follows: Category.php</strong></span></p>
<ol>
<ol>
<li>We declared field such as <b>name</b> in this class.</li>
<li>Further we did the mapping of this entity with another entity <strong>SubCategory</strong> in <b>one-to -many </b>relationship.</li>
<li>Again, we did the mapping of this entity with another entity named as <strong>CategorySubCategories</strong> in <strong>o</strong><b>ne-to-many</b> relationship.</li>
<li>This entity is further mapped with another entity <strong>Tr</strong><strong>ademarkquesionnaire</strong> in <b>many-to-one </b> relationship.</li>
<li>We define two function <b>_toString() </b>and <b> _construct() </b> for converting object into string and to initialize the components respectively.</li>
</ol>
</ol>
<p><a href="http://webmuch.com/how-to-create-symfony2-collection-form-using-symfony2-form-component/doctrine_image_2/" rel="attachment wp-att-15386"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-15386" src="http://webmuch.com/wp-content/uploads/2015/01/doctrine_image_2.png" alt="doctrine_image_2" width="394" height="442" srcset="https://webmuch.com/wp-content/uploads/2015/01/doctrine_image_2.png 394w, https://webmuch.com/wp-content/uploads/2015/01/doctrine_image_2-100x112.png 100w" sizes="auto, (max-width: 394px) 100vw, 394px" /></a></p>
<pre class="lang:default decode:true">/*** @var string
** @ORM\Column(name="name", type="string", length=255)
*/
private $name;

/**
** @ORM\OneToMany(targetEntity="Subcategory", mappedBy="category", cascade={"persist", "remove"})
**/

private $subcategory;

/**
* @ORM\OneToMany(targetEntity="Webmuch\TrademarkBundle\Entity\CategorySubCategory", mappedBy="category")
**/
private $categorySubCategories;

/**
* @ORM\ManyToMany(targetEntity="Webmuch\TrademarkBundle\Entity\TrademarkQuestionnaire", mappedBy="categories")
**/

private $trademarks;public function __toString(){return (string)$this-&gt;name;}

/**
* Constructor
*/

public function __construct(){

	$this-&gt;subcategory = new ArrayCollection();

}</pre>
<p>&nbsp;</p>
<p>We then generated the getter and setter method for the above fields by running the given commands on the Symfony2 console:</p>
<pre class="lang:default decode:true">$ php app/console doctrine:generate:entities /webmuch/trademarkBundle/Entity/Category
$ php app/console doctrine:schema:update --force</pre>
<p><strong><span style="text-decoration: underline;">Create the subcategory entity as follows: Subcategory.php.</span></strong></p>
<ol>
<li>We declared the field &#8216;<b>productName&#8217; </b>which is of type string.</li>
<li>Then we map the <strong>SubCategory</strong> entity with the previously created entity category in <b>many-to-one</b> relationship.</li>
<li><strong>SubCategory</strong> entity is further mapped with <strong>C</strong><strong>ategorySubCategories</strong> entity in <b>many-to-many</b> relationship.</li>
<li>We define  function <b>_toString() </b>function to convert objects into string.
<pre class="lang:default decode:true">/**
* @var string** @ORM\Column(name="productName", type="string", length=255)
*/
private $productName;

/**
* @ORM\ManyToOne(targetEntity="Category", inversedBy="subcategory")
* @ORM\JoinColumn(name="category_id", referencedColumnName="id")
**/
private $category;

/**
* @ORM\ManyToMany(targetEntity="Webmuch\TrademarkBundle\Entity\CategorySubCategory", mappedBy="subCategories")
**/
private $categorySubCategories;

public function __toString(){
	return (String)$this-&gt;productName;
}</pre>
</li>
<li>Now generate the get() and set() methods for the above defined fields by compiling the following commands
<pre class="lang:default decode:true ">$ php app/console doctrine:generate:entities /webmuch/TrademarkBundle/Entity/SubCategory
$ php app/console doctrine:schema:update --force</pre>
<p>&nbsp;</li>
</ol>
<p><strong><span style="text-decoration: underline;">Create the subcategory entity as follows: CategorySubCategory.php</span></strong></p>
<p>First, we map this entity with category entity in <b>many-to-one </b>relationship. Again, we map this entity with <strong>subcategories</strong> entity in <b>many-to-many</b> relationship. This particular entity is mapped again with Trademarkquesionnaire entity in <b>many-to-many </b>relationship. Now,define the two function <b>_toString() </b>function to convert objects into string .</p>
<p><a href="http://webmuch.com/create-symfony2-collection-form-using-symfony2-form-component/er-diagram-2/" rel="attachment wp-att-15502"><img loading="lazy" decoding="async" class="aligncenter wp-image-15502" src="http://webmuch.com/wp-content/uploads/2015/02/ER-diagram1.png" alt="ER-diagram" width="700" height="378" srcset="https://webmuch.com/wp-content/uploads/2015/02/ER-diagram1.png 1066w, https://webmuch.com/wp-content/uploads/2015/02/ER-diagram1-100x54.png 100w, https://webmuch.com/wp-content/uploads/2015/02/ER-diagram1-979x529.png 979w" sizes="auto, (max-width: 700px) 100vw, 700px" /></a></p>
<pre class="lang:default decode:true">/**
* @ORM\ManyToOne(targetEntity="Webmuch\TrademarkBundle\Entity\Category", inversedBy="categorySubCategories")
* @ORM\JoinColumn(name="category_id", referencedColumnName="id")
**/
private $category;

/**
* @ORM\ManyToMany(targetEntity="Webmuch\TrademarkBundle\Entity\Subcategory", inversedBy="categorySubCategories",cascade={"persist"})
* @ORM\JoinTable(name="categorySubCategories_subcategories")
**/
private $subCategories;

/**
* @ORM\ManyToMany(targetEntity="Webmuch\TrademarkBundle\Entity\TrademarkQuestionnaire", mappedBy="categorySubCategories")
**/
private $trademarks;

public function __toString(){
    return (String)$this-&gt;id;
}

//Here we generate the get() and set() methods for the above define field by running the following commands on console.

$ php app/console doctrine:generate:entities /webmuch/TrademarkBundle/Entity/ CategorySubCategory
$ php app/console doctrine:schema:update –force</pre>
<p>&nbsp;</p>
<p><span style="text-decoration: underline;"><strong>Create the subcategory entity as follows: trademarkQuestionnaire.php</strong></span></p>
<p>We map the <strong>Trademarkquestionnaire </strong>entity with another entity <strong>CategorySubategory </strong>in <strong>m</strong><b>any-to-many </b>relationship. We define two function <b>_toString() </b>function to convert objects into string.</p>
<p>After defining the functions we generated the get() and set() methods for the above defined field by running the following commands on console.</p>
<p>Symfony2 Collection Form is to manage a group of similar items. In this file various actions were created through CRUD generation among which we modified the CreateAction() and UpdateAction() methods.</p>
<pre class="lang:default decode:true">/**
* @ORM\ManyToMany(targetEntity="Webmuch\TrademarkBundle\Entity\CategorySubCategory", inversedBy="trademarks", cascade={ "persist", "remove" })
* @ORM\JoinTable(name="trademarks_categorySubCategories")
**/
private $categorySubCategories;</pre>
<p>Both the methods, before final submissions of data, the Subcategory entity&#8217;s fields were called to enter the values of subcategory for each category. As we have done one to many mapping of category entity with subcategory entity.</p>
<pre class="lang:default decode:true">$ php app/console doctrine:generate:entities /webmuch/TrademarkBundle/Entity/TrademarkQuestionnaire

$ php app/console doctrine:schema:update --force</pre>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h3>Forms</h3>
<ol>
<li><span style="text-decoration: underline;"><strong>CategoryType.php<br />
</strong></span>We import the following statement on the top of file to inherit SubcategoryType form in this file</p>
<pre class="lang:default decode:true">use Webmuch\TrademarkBundle\Form\SubcategoryType;

    -&gt;add('subcategory','collection',array('type' =&gt; new SubcategoryType(),
     'allow_add' =&gt; true,
     'allow_delete' =&gt; true,
     'options' =&gt; array('label' =&gt; false),
     ))</pre>
<p>In build form function we add collection of subcategory and allow the add and delete functionality to be true, which is by default false.</li>
</ol>
<ol start="2">
<li><span style="text-decoration: underline;"><strong>SubcategoryType.php</strong></span>
<pre class="lang:default decode:true">SubcategoryType.php-&gt;add('productName')</pre>
<p>&nbsp;</li>
</ol>
<ol start="3">
<li><b><span style="text-decoration: underline;">CategorySubCategoryType.php<br />
</span></b>It is the most important part of the blog, because it is the actual form by which we are able to combine the <strong>Category(attribute)</strong> and <strong>SubCategory(value)</strong> in  <strong>Trademarkquesionnaire(entity)</strong> form where we select a <strong>category</strong>(<strong>attribute</strong>), the relevant <strong>subcategories</strong>(<strong>values</strong>) are displayed.<br />
First we import the following statement on top of the file to use the fields of subcategory entity. In bulidform function we add two EventListners for <strong>PRE_SET_DATA</strong> and <strong>PRE_SUBMIT</strong> . We define two functions <strong>onPreSubmit()</strong> and <strong>onPreSetData()</strong> to get the values to be stored for different categories and subcategories. Also, we define a function <strong>Addelements()</strong> to various <strong>subcategories</strong> to single <strong>category</strong>.<br />
This function also arrange various subcategories into ascending order.<b><br />
</b></li>
</ol>
<pre class="lang:default decode:true">use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormInterface;

use Webmuch\TrademarkBundleBundle\Entity\Category;
use Webmuch\TrademarkBundle\Entity\SubCategory;

public function buildForm(FormBuilderInterface $builder, array $options)
{
	$builder-&gt;addEventListener(FormEvents::PRE_SET_DATA, array($this, 'onPreSetData'));
	$builder-&gt;addEventListener(FormEvents::PRE_SUBMIT, array($this, 'onPreSubmit'));
}

protected function addElements(FormInterface $form, Category $category = null) {
	$em = $this-&gt;getEntityManager();
	
	// Add the Category element
	$form-&gt;add('Category', 'entity', array(
		'data' =&gt; $category,
		'empty_value' =&gt; '-- Select a Category first --',
		'class' =&gt; 'WebmuchTrademarkBundle:Category',
		'mapped' =&gt; true)
	);

	// SubCategorys are empty, unless we actually supplied a Category
	$subCagories = array();
	if ($category) {
		// Fetch the SubCategorys from specified Category
		$repo = $em-&gt;getRepository('WebmuchTrademarkBundle:SubCategory');
		$subCagories = $repo-&gt;findByCategory($category, array('productName' =&gt; 'asc'));
	}

	// Add the SubCategorys element
	$form-&gt;add('subCategories', 'entity', array(
		'empty_value' =&gt; '-- Select a Category first --',
		'class' =&gt; 'WebmuchTrademarkBundle:SubCategory',
		'choices' =&gt; $subCagories,
		'multiple' =&gt; true,
	));
}

function onPreSubmit(FormEvent $event) {
	$em = $this-&gt;getEntityManager();
	$form = $event-&gt;getForm();
	$data = $event-&gt;getData();

	// Note that the data is not yet hydrated into the entity.
	if(isset($data['Category'])){
	$category = $em-&gt;getRepository('WebmuchTrademarkBundle:Category')-&gt;find($data['Category']);
	$this-&gt;addElements($form, $category);
	}
}

function onPreSetData(FormEvent $event) {
	$em = $this-&gt;getEntityManager();
	$data = $event-&gt;getData();
	if($data instanceof \Webmuch\TrademarkBundle\Entity\CategorySubCategory ) {
	$category = $data-&gt;getCategory(); 
	}
	else { 
		$category = $event-&gt;getData();
	}
	$this-&gt;addElements($event-&gt;getForm(), $category); 
}</pre>
<p>Then after we will have to manage to make a system such that after selecting a category, the relevant subcategories are displayed. This can be achieved by writing the Ajax function and passing the Ajax url to the controller method.</p>
<p><strong>We have need to create a controller method to fetch the subcategories by category in AJAX call .</strong></p>
<pre class="lang:default decode:true">/**
* Displays a form to create a ajaxCall Product entity.
*
* @Route("/subCategoriesAjaxCall", name="category_subCategories_ajax_call")
* @Method("GET")
* @Template()
*/

public function ajaxAction(Request $request) {

/*if (! $request-&gt;isXmlHttpRequest()) {
    throw new NotFoundHttpException();
}*/

$em = $this-&gt;getDoctrine()-&gt;getManager();

// Get the province ID

$id = $request-&gt;query-&gt;get('category');
$category = $em-&gt;getRepository("WebmuchTrademarkBundle:Category")-&gt;findOneBy(array('id' =&gt; $id));
$result = array();

// Return a list of vendors, based on the selected province

$repo = $em-&gt;getRepository('WebmuchTrademarkBundle:SubCategory');
$subCategories = $repo-&gt;findBy(array('category' =&gt; $category));

// Fetching the title of each feature values

foreach ($subCategories as $subCategory) {
$result[$subCategory-&gt;getProductName()] = $subCategory-&gt;getId();
}

//print_r($vendors);die();
return new JsonResponse($result);
}
}</pre>
<ol start="4">
<li><b><span style="text-decoration: underline;">TrademarkQuestionnaireType.php<br />
</span></b>In these form type, we import the following statement on the top of file. In bulidform() function, we add Collection Form of categorySubCategory so that the User can select many Subcategory for a single Category.</li>
</ol>
<pre class="lang:default decode:true  ">use Webmuch\TrademarkBundle\Form\CategorySubCategoryType;
-&gt;add('categorySubCategories','collection',array(
    'type' =&gt; new CategorySubCategoryType(),
    'allow_add' =&gt; true,
    'allow_delete' =&gt; true,
))</pre>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="http://webmuch.com/how-to-create-symfony2-collection-form-using-symfony2-form-component/collection/" rel="attachment wp-att-15388"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-15388" src="http://webmuch.com/wp-content/uploads/2015/01/collection.jpg" alt="collection" width="638" height="452" srcset="https://webmuch.com/wp-content/uploads/2015/01/collection.jpg 638w, https://webmuch.com/wp-content/uploads/2015/01/collection-100x71.jpg 100w" sizes="auto, (max-width: 638px) 100vw, 638px" /></a></p>
<p>&nbsp;</p>
<h3>Controller</h3>
<p>After creating the above mentioned entities we write the controllers of these entities.</p>
<p><a href="http://webmuch.com/how-to-create-symfony2-collection-form-using-symfony2-form-component/mvc/" rel="attachment wp-att-15390"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-15390" src="http://webmuch.com/wp-content/uploads/2015/01/mvc.png" alt="mvc" width="500" height="400" srcset="https://webmuch.com/wp-content/uploads/2015/01/mvc.png 500w, https://webmuch.com/wp-content/uploads/2015/01/mvc-100x80.png 100w" sizes="auto, (max-width: 500px) 100vw, 500px" /></a></p>
<pre class="lang:default decode:true">$php app/console doctrine:generate:crud</pre>
<p>&nbsp;</p>
<ol>
<li><span style="text-decoration: underline;"><strong>CategoryController.php</strong></span></li>
</ol>
<p>In this Controller we have to import the following statement on the top of the file :</p>
<pre class="lang:default decode:true">use Doctrine\Common\Collections\ArrayCollection;

// create action
public function Create Action(Request $request){
	if ($form-&gt;isValid()) {
			$subcategories = $form-&gt;getData()-&gt;getSubCategory();
			$em = $this-&gt;getDoctrine()-&gt;getManager();
			foreach($subcategories as $subcategory){
				$subcategory-&gt;setCategory($entity);
		}

	$em-&gt;persist($entity);
	$em-&gt;flush();
	return $this-&gt;redirect($this-&gt;generateUrl('category_show', array('id' =&gt; $entity-&gt;getId(       ))));
    }
}
// Update Action
public function updateAction(Request $request, $id)
{
	$em = $this-&gt;getDoctrine()-&gt;getManager();
	$entity = $em-&gt;getRepository('WebmuchTrademarkBundle:Category')-&gt;find($id);
	$originalSubCategories = new ArrayCollection();
	foreach($entity-&gt;getSubCategory() as $subcategory){
		$originalSubCategories-&gt;add($subcategory);
	}
	
	if (!$entity) {
		throw $this-&gt;createNotFoundException('Unable to find Category entity.');
	}

	$deleteForm = $this-&gt;createDeleteForm($id);
	$editForm = $this-&gt;createEditForm($entity);
	$editForm-&gt;handleRequest($request);
	if($editForm-&gt;isValid()){
		foreach ($originalSubCategories as $subcategory) {
			if (false === $entity-&gt;getSubCategory()-&gt;contains($subcategory)) {
				$em-&gt;remove($subcategory);
			}
		}

	$subcategories = $editForm-&gt;getData()-&gt;getSubCategory();
	$em = $this-&gt;getDoctrine()-&gt;getManager();
	foreach($subcategories as $subcategory){
	$subcategory-&gt;setCategory($entity);

	$em-&gt;persist($subcategory);
	$em-&gt;flush();
	}

	$em-&gt;persist($entity);
	$em-&gt;flush();

	return $this-&gt;redirect($this-&gt;generateUrl('category_edit', array('id' =&gt; $id)));
}</pre>
<p>&nbsp;</p>
<p><b>HTML TWIG FILES</b></p>
<ol>
<li><span style="text-decoration: underline;"><strong>Category</strong></span></li>
</ol>
<p>//index.html.twig (No modifications were made to the default code)</p>
<p>//new.html.twig</p>
<p>We called a class of type subcategory.<br />
Created a Subcategory collectionHolder to store various Subcategories of a particular category into this Collection Form.<br />
Create a link for adding many Subcategories for a particular category. This is achived through addTagForm() method.<br />
Create a link for deleting Subcategories for a particular category. This is achived through addTagForm Delete link() method.</p>
<p><b>Css Block</b></p>
<pre class="lang:default decode:true" title="CSS">{{ form_start(form) }}

    {{ form_widget(form.name) }}
    &lt;ul class="subcategory" data-prototype="{{ form_widget(form.subcategory.vars.prototype)|e }}"&gt;&lt;/ul&gt;

{{ form_rest(form) }}</pre>
<p><b>Javascript Block</b></p>
<pre class="lang:default decode:true">{% block javascripts %}
	{{ parent() }}
	//call the parent class

	&lt;script type="text/javascript"&gt;
		var $subCategoryCollectionHolder = $('ul.subcategory');
		//set the all data object in bundle
		// setup an "add a tag" link
		var $addSubCategoryLink = $('&lt;a href="#" class="add_tag_link"&gt;Add Subcategory&lt;/a&gt;');
		var $newSubCategoryLink = $('&lt;li&gt;&lt;/li&gt;').append($addSubCategoryLink);
		var childFormLength = '{{ form.subcategory|length }}';
		
		jQuery(document).ready(function() {
			// Get the ul that holds the collection of subcategory
				$subCategoryCollectionHolder = $('ul.subcategory');
				// add a delete link to all of the existing tag form li elements
				$subCategoryCollectionHolder.find('li').each(function() {
				addTagFormDeleteLink($(this));
			});

			// add the "add a tag" anchor and li to the subcategory ul
			$subCategoryCollectionHolder.append($newSubCategoryLink);

			// add new form on click on add new link
			$addSubCategoryLink.on('click', function(e) {

				// prevent the link from creating a "#" on the URL
				e.preventDefault();

				// add a new tag form (see the next code block)
				addTagForm($subCategoryCollectionHolder, $newSubCategoryLink);
				childFormLength++;
				// call the subcagories in use childFormLength++
			});
		});

		function addTagForm($subCategoryCollectionHolder, $newSubCategoryLink) {
			// Get the data-prototype explained earlier
			var prototype = $subCategoryCollectionHolder.data('prototype');

			// Replace '__name__' in the prototype's HTML to
			// instead be a number based on how many items we have

			var newForm = prototype.replace(/__name__/g, childFormLength);
			//childFormLength++;
			// Display the form in the page in an li, before the "Add a tag" link li
			var $newFormLi = $('&lt;li&gt;&lt;/li&gt;').append(newForm);
			$newSubCategoryLink.before($newFormLi);
			addTagFormDeleteLink($newFormLi);
		}

		function addTagFormDeleteLink($tagFormLi) {

			var $removeFormA = $('&lt;a href="#"&gt;delete this Subcategory&lt;/a&gt;');
			$tagFormLi.append($removeFormA);
			$removeFormA.on('click', function(e) {
				// prevent the link from creating a "#" on the URL
				e.preventDefault();
				// remove the li for the tag form
				$tagFormLi.remove();
			});
		}
	&lt;/script&gt;</pre>
<p>Show.html.twig(No modifications were made to the default code.)</p>
<p>Edit.html.Twig (New file is added in the new.html.twig file)</p>
<ol start="2">
<li><span style="text-decoration: underline;"><strong>CategorySubCategory</strong></span></li>
</ol>
<p>Index.html.twig(No modifications were mode to the default code.)</p>
<p>In this file, inside the javascript tags, document ready() function is called for enabling the Subcategories to be added to the Category for every loading of the page.</p>
<p>&nbsp;</p>
<p><b>Css block</b></p>
<pre class="lang:default decode:true" title="Css">{% block body -%}
    &lt;h1&gt;CategorySubCategory creation&lt;/h1&gt;
    {{ form(form) }}
    &lt;ul class="record_actions"&gt;
        &lt;li&gt;&lt;a href="{{ path('categorysubcategory') }}"&gt;Back to the list&lt;&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
{% endblock %}

{% block javascripts %}
    {{ parent() }}
    &lt;script type="text/javascript"&gt;
        $(document).ready(function () {
        $('#webmuch_trademarkbundle_categorysubcategory_Category').change        (function(){
            var val = $(this).val();
            $.ajax({type: "get",
            url: "{{ url('category_subCategories_ajax_call') }}?category=            " + val,
            success: function(data) {
                // Remove current options
                $('#webmuch_trademarkbundle_categorysubcategory_subCategories').html('');
                //Rendor new options
                $.each(data, function(k, v) {
                    alert($('#webmuch_trademarkbundle_categorysubcategory_subCategories').append('&lt;option value="' + v + '"&gt;' + k + '&lt;/option&gt;'));
                });
            }
        });
        return false;
    });
});
&lt;/script&gt;
{% endblock %}</pre>
<p>&nbsp;</p>
<p>Show.html.twig (No modifications were made to the default code)<br />
Edit.html.Twig (No modifications were made to the default code)</p>
<p>&nbsp;</p>
<ol start="3">
<li><span style="text-decoration: underline;"><b>TrademarkQuestionnaire</b></span></li>
</ol>
<p>In new.html.twig file, we add a new button loaded as add + to select categories and its respective Subcategories. For this purpose inside the javascript tags. We created a collectionHolder variable and added to it, CategorySubCategoryAddValueLink. Also, we added a delete link to the collectionHolder to delete any existing SubCategory and Categories. For both these functionalities, we defined two separate functions categorySubCategories AddValueForm and CategorySubCategory AddTagFormDeleteLink().</p>
<p>&nbsp;</p>
<pre class="lang:default decode:true">&lt;script type="text/javascript"&gt;
    var collectionHolder = $('ul.categorySubCategories');
    var valueCount = '{{ form.categorySubCategories|length }}';

    // setup an "add a value" link
    var $addValueLink = $('&lt;a href="#" class="btn btn-primary btn-small"&gt;add+&lt;/a&gt;');
    var $newLinkLi = $('&lt;li&gt;&lt;/li&gt;').append($addValueLink);

    jQuery(document).ready(function()
    {
        $collectionHolder = $('ul.value');

        // add a delete link to all of the existing value form li elements
        $collectionHolder.find('li').each(function()
        {
            addTagFormDeleteLink($(this));
        });

        // add the "add a value" anchor and li to the categorySubCategories ul
        collectionHolder.append($newLinkLi);
        
        // action performed on clicked
        $addValueLink.on('click', function(e) {

            // prevent the link from creating a "#" on the URL
            e.preventDefault();

            // add a new value form (see next code block)
            addValueForm(collectionHolder, $newLinkLi);
            valueCount++;
        });
    });

    function addValueForm(collectionHolder, $newLinkLi) {
        //Get the exixting count of value
        // Get the data-prototype we explained earlier
        var prototype = collectionHolder.attr('data-prototype-categorySubCategories');
        // Replace '__name__' in the prototype's HTML to
        // instead be a number based on the current collection's length.
        var newForm = prototype.replace(/__name__/g, valueCount);
        // Display the form in the page in an li, before the "Add a value" link li
        var $newFormLi = $('&lt;li&gt;&lt;/li&gt;').append(newForm);
        $newLinkLi.before($newFormLi);

        // add a delete link to the new form
        addTagFormDeleteLink($newFormLi);
    }

    function addTagFormDeleteLink($valueFormLi) {
        var $removeFormA = $('&lt;a href="#" class="btn btn-danger btn-small"&gt;del-&lt;/a&gt;');
        $valueFormLi.append($removeFormA);
        $removeFormA.on('click', function(e) {
            // prevent the link from creating a "#" on the URL
            e.preventDefault();
            // remove the li for the value form
            $valueFormLi.remove();
        });
    }
&lt;/script&gt;

&lt;script type="text/javascript"&gt;
    $('#select').on('change', 'select:not(select[multiple=multiple])', function() {
        var $cSelect = $(this);
        var $nextMultiSel = $("#"+$cSelect.attr('id').slice(0,-8)+"subCategories").css("height","100");
        console.log("clicked at ?");
        $.ajax({
            type: "get",
            url: "{{ url('category_subCategories_ajax_call') }}?category=" + $cSelect.val(),
            success: function(data) {
                // Remove current options
                console.log("fetched");
                $nextMultiSel.html('');
                //Rendor new options
                $.each(data, function(k, v) {
                   $nextMultiSel.append('&lt;option value="' + v + '"&gt;' + k + '&lt;/option&gt;');
                });
            }
        });
        return false;
    });
&lt;/script&gt;
{% endblock %}</pre>
<p>Well, I hope you&#8217;ve embeded your EAV model in Symfony2 Collection Form. Hope this helped!</p>
<p>Please do share the tutorial if you appreciate it at all. And for any doubts, please mention your query in the comments section below.</p>
<p>Happy Reading!</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h3>MORE AWESOME TUTORIALS</h3>
<ol>
<li><a href="http://webmuch.com/override-fosuserbundle/">How To Override FOSUserBundle &#8211; TUTORIAL</a><a href="http://webmuch.com/override-fosuserbundle/symfonyplusfos/" rel="attachment wp-att-15674"><br />
</a><a href="http://webmuch.com/override-fosuserbundle/" rel="attachment wp-att-15674"><img loading="lazy" decoding="async" class="alignnone wp-image-15674" src="http://webmuch.com/wp-content/uploads/2015/02/symfonyplusfos.png" alt="symfonyplusfos" width="250" height="188" srcset="https://webmuch.com/wp-content/uploads/2015/02/symfonyplusfos.png 638w, https://webmuch.com/wp-content/uploads/2015/02/symfonyplusfos-100x75.png 100w" sizes="auto, (max-width: 250px) 100vw, 250px" /></a></li>
<li><a href="http://webmuch.com/create-multi-column-design-layout-using-wookmark-jquery/">How To Create A Multi Column Design Layout Using Wookmark jQuery &#8211; TUTORIAL</a><br />
<a href="http://webmuch.com/create-multi-column-design-layout-using-wookmark-jquery/" rel="attachment wp-att-15389"><img loading="lazy" decoding="async" class="alignnone wp-image-15389" src="http://webmuch.com/wp-content/uploads/2015/01/jquery-wookmark-1.jpg" alt="wookmark jquery" width="250" height="127" srcset="https://webmuch.com/wp-content/uploads/2015/01/jquery-wookmark-1.jpg 750w, https://webmuch.com/wp-content/uploads/2015/01/jquery-wookmark-1-100x51.jpg 100w" sizes="auto, (max-width: 250px) 100vw, 250px" /></a></li>
<li><a href="http://webmuch.com/create-business-application-data-grid-oro-platform/">How To Create A Business Application In Data Grid &#8211; ORO Platform &#8211; TUTORIAL</a><br />
<a href="http://webmuch.com/create-business-application-data-grid-oro-platform/"><img loading="lazy" decoding="async" class="alignnone wp-image-15379" src="http://webmuch.com/wp-content/uploads/2015/01/oro-plateform-1.jpg" alt="Oro Platform" width="250" height="112" srcset="https://webmuch.com/wp-content/uploads/2015/01/oro-plateform-1.jpg 1119w, https://webmuch.com/wp-content/uploads/2015/01/oro-plateform-1-100x45.jpg 100w, https://webmuch.com/wp-content/uploads/2015/01/oro-plateform-1-979x437.jpg 979w" sizes="auto, (max-width: 250px) 100vw, 250px" /></a></li>
<li><a href="http://webmuch.com/image-flip-using-jquery/">Image Flip Using jQuery</a><a href="http://webmuch.com/image-flip-using-jquery/imageflip/" rel="attachment wp-att-305"><br />
</a><a href="http://webmuch.com/image-flip-using-jquery/" rel="attachment wp-att-305"><img loading="lazy" decoding="async" class="alignnone wp-image-305" src="http://webmuch.com/wp-content/uploads/2009/06/imageflip.jpg" alt="imageflip" width="250" height="177" /></a></li>
</ol>
<p>The post <a href="https://webmuch.com/embed-eav-model-symfony2-collection-form/">How To Embed EAV Model In Symfony2 Collection Form</a> appeared first on <a href="https://webmuch.com">Webmuch</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://webmuch.com/embed-eav-model-symfony2-collection-form/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
